titlebar: remove
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
e9ef51a521
commit
371ee3e8cc
|
@ -58,7 +58,6 @@ set(AWE_SRCS
|
||||||
${SOURCE_DIR}/objects/wibox.c
|
${SOURCE_DIR}/objects/wibox.c
|
||||||
${SOURCE_DIR}/systray.c
|
${SOURCE_DIR}/systray.c
|
||||||
${SOURCE_DIR}/objects/tag.c
|
${SOURCE_DIR}/objects/tag.c
|
||||||
${SOURCE_DIR}/titlebar.c
|
|
||||||
${SOURCE_DIR}/objects/widget.c
|
${SOURCE_DIR}/objects/widget.c
|
||||||
${SOURCE_DIR}/window.c
|
${SOURCE_DIR}/window.c
|
||||||
${SOURCE_DIR}/image.c
|
${SOURCE_DIR}/image.c
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "property.h"
|
#include "property.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "titlebar.h"
|
|
||||||
#include "luaa.h"
|
#include "luaa.h"
|
||||||
#include "common/version.h"
|
#include "common/version.h"
|
||||||
#include "common/atoms.h"
|
#include "common/atoms.h"
|
||||||
|
@ -87,10 +86,7 @@ awesome_atexit(void)
|
||||||
|
|
||||||
/* remap all clients since some WM won't handle them otherwise */
|
/* remap all clients since some WM won't handle them otherwise */
|
||||||
foreach(c, globalconf.clients)
|
foreach(c, globalconf.clients)
|
||||||
{
|
|
||||||
client_unban(*c);
|
client_unban(*c);
|
||||||
titlebar_client_detach(*c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Close Lua */
|
/* Close Lua */
|
||||||
lua_close(globalconf.L);
|
lua_close(globalconf.L);
|
||||||
|
|
|
@ -305,9 +305,6 @@ awful.rules.rules = {
|
||||||
-- {{{ Signals
|
-- {{{ Signals
|
||||||
-- Signal function to execute when a new client appears.
|
-- Signal function to execute when a new client appears.
|
||||||
client.add_signal("manage", function (c, startup)
|
client.add_signal("manage", function (c, startup)
|
||||||
-- Add a titlebar
|
|
||||||
-- awful.titlebar.add(c, { modkey = modkey })
|
|
||||||
|
|
||||||
-- Enable sloppy focus
|
-- Enable sloppy focus
|
||||||
c:add_signal("mouse::enter", function(c)
|
c:add_signal("mouse::enter", function(c)
|
||||||
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
|
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
|
||||||
|
|
28
banning.c
28
banning.c
|
@ -22,7 +22,6 @@
|
||||||
#include "banning.h"
|
#include "banning.h"
|
||||||
#include "objects/tag.h"
|
#include "objects/tag.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "titlebar.h"
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
/** Reban windows following current selected tags.
|
/** Reban windows following current selected tags.
|
||||||
|
@ -56,31 +55,16 @@ reban(screen_t *screen)
|
||||||
|
|
||||||
client_ignore_enterleave_events();
|
client_ignore_enterleave_events();
|
||||||
|
|
||||||
foreach(_c, globalconf.clients)
|
foreach(c, globalconf.clients)
|
||||||
{
|
if(client_isvisible(*c, screen))
|
||||||
client_t *c = *_c;
|
client_unban(*c);
|
||||||
|
|
||||||
/* Restore titlebar before client, so geometry is ok again. */
|
|
||||||
if(titlebar_isvisible(c, screen))
|
|
||||||
titlebar_unban(c->titlebar);
|
|
||||||
|
|
||||||
if(client_isvisible(c, screen))
|
|
||||||
client_unban(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Some people disliked the short flicker of background, so we first unban everything.
|
/* Some people disliked the short flicker of background, so we first unban everything.
|
||||||
* Afterwards we ban everything we don't want. This should avoid that. */
|
* Afterwards we ban everything we don't want. This should avoid that. */
|
||||||
foreach(_c, globalconf.clients)
|
foreach(c, globalconf.clients)
|
||||||
{
|
|
||||||
client_t *c = *_c;
|
|
||||||
|
|
||||||
if(!titlebar_isvisible(c, screen) && c->screen == screen)
|
|
||||||
titlebar_ban(c->titlebar);
|
|
||||||
|
|
||||||
/* we don't touch other screens windows */
|
/* we don't touch other screens windows */
|
||||||
if(!client_isvisible(c, screen) && c->screen == screen)
|
if(!client_isvisible(*c, screen) && (*c)->screen == screen)
|
||||||
client_ban(c);
|
client_ban(*c);
|
||||||
}
|
|
||||||
|
|
||||||
client_restore_enterleave_events();
|
client_restore_enterleave_events();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ button_release
|
||||||
center
|
center
|
||||||
char
|
char
|
||||||
class
|
class
|
||||||
client
|
|
||||||
conffile
|
conffile
|
||||||
content
|
content
|
||||||
Control
|
Control
|
||||||
|
@ -75,7 +74,6 @@ orientation
|
||||||
pid
|
pid
|
||||||
plot_data_add
|
plot_data_add
|
||||||
plot_properties_set
|
plot_properties_set
|
||||||
position
|
|
||||||
release
|
release
|
||||||
resize
|
resize
|
||||||
right
|
right
|
||||||
|
@ -100,7 +98,6 @@ textbox
|
||||||
ticks_count
|
ticks_count
|
||||||
ticks_gap
|
ticks_gap
|
||||||
timeout
|
timeout
|
||||||
titlebar
|
|
||||||
top
|
top
|
||||||
transient_for
|
transient_for
|
||||||
type
|
type
|
||||||
|
|
27
event.c
27
event.c
|
@ -32,7 +32,6 @@
|
||||||
#include "ewmh.h"
|
#include "ewmh.h"
|
||||||
#include "objects/client.h"
|
#include "objects/client.h"
|
||||||
#include "objects/widget.h"
|
#include "objects/widget.h"
|
||||||
#include "titlebar.h"
|
|
||||||
#include "objects/key.h"
|
#include "objects/key.h"
|
||||||
#include "keygrabber.h"
|
#include "keygrabber.h"
|
||||||
#include "mousegrabber.h"
|
#include "mousegrabber.h"
|
||||||
|
@ -250,11 +249,10 @@ event_handle_configurerequest(void *data __attribute__ ((unused)),
|
||||||
xcb_connection_t *connection, xcb_configure_request_event_t *ev)
|
xcb_connection_t *connection, xcb_configure_request_event_t *ev)
|
||||||
{
|
{
|
||||||
client_t *c;
|
client_t *c;
|
||||||
area_t geometry;
|
|
||||||
|
|
||||||
if((c = client_getbywin(ev->window)))
|
if((c = client_getbywin(ev->window)))
|
||||||
{
|
{
|
||||||
geometry = titlebar_geometry_remove(c->titlebar, c->border_width, c->geometry);
|
area_t geometry = c->geometries.internal;
|
||||||
|
|
||||||
if(ev->value_mask & XCB_CONFIG_WINDOW_X)
|
if(ev->value_mask & XCB_CONFIG_WINDOW_X)
|
||||||
geometry.x = ev->x;
|
geometry.x = ev->x;
|
||||||
|
@ -277,13 +275,14 @@ event_handle_configurerequest(void *data __attribute__ ((unused)),
|
||||||
XCB_CONFIG_WINDOW_STACK_MODE);
|
XCB_CONFIG_WINDOW_STACK_MODE);
|
||||||
|
|
||||||
/** Configure request are sent with size relative to real (internal)
|
/** Configure request are sent with size relative to real (internal)
|
||||||
* window size, i.e. without titlebars and borders. */
|
* window size, i.e. without borders. */
|
||||||
geometry = titlebar_geometry_add(c->titlebar, c->border_width, geometry);
|
geometry.width += 2 * c->border_width;
|
||||||
|
geometry.height += 2 * c->border_width;
|
||||||
|
|
||||||
if(!client_resize(c, geometry, false))
|
if(!client_resize(c, geometry, false))
|
||||||
{
|
{
|
||||||
/* Resize wasn't officially needed, but we don't want to break expectations. */
|
geometry.width -= 2 * c->border_width;
|
||||||
geometry = titlebar_geometry_remove(c->titlebar, c->border_width, c->geometry);
|
geometry.height -= 2 * c->border_width;
|
||||||
window_configure(c->window, geometry, c->border_width);
|
window_configure(c->window, geometry, c->border_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -415,7 +414,7 @@ event_handle_leavenotify(void *data __attribute__ ((unused)),
|
||||||
if(ev->mode != XCB_NOTIFY_MODE_NORMAL)
|
if(ev->mode != XCB_NOTIFY_MODE_NORMAL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if((c = client_getbytitlebarwin(ev->event)) || (c = client_getbywin(ev->event)))
|
if((c = client_getbywin(ev->event)))
|
||||||
{
|
{
|
||||||
luaA_object_push(globalconf.L, c);
|
luaA_object_push(globalconf.L, c);
|
||||||
luaA_object_emit_signal(globalconf.L, -1, "mouse::leave", 0);
|
luaA_object_emit_signal(globalconf.L, -1, "mouse::leave", 0);
|
||||||
|
@ -471,8 +470,7 @@ event_handle_enternotify(void *data __attribute__ ((unused)),
|
||||||
lua_pop(globalconf.L, 1);
|
lua_pop(globalconf.L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((c = client_getbytitlebarwin(ev->event))
|
if((c = client_getbywin(ev->event)))
|
||||||
|| (c = client_getbywin(ev->event)))
|
|
||||||
{
|
{
|
||||||
luaA_object_push(globalconf.L, c);
|
luaA_object_push(globalconf.L, c);
|
||||||
luaA_object_emit_signal(globalconf.L, -1, "mouse::enter", 0);
|
luaA_object_emit_signal(globalconf.L, -1, "mouse::enter", 0);
|
||||||
|
@ -492,8 +490,6 @@ event_handle_focusin(void *data __attribute__ ((unused)),
|
||||||
xcb_connection_t *connection,
|
xcb_connection_t *connection,
|
||||||
xcb_focus_in_event_t *ev)
|
xcb_focus_in_event_t *ev)
|
||||||
{
|
{
|
||||||
client_t *c;
|
|
||||||
|
|
||||||
/* Events that we are interested in: */
|
/* Events that we are interested in: */
|
||||||
switch(ev->detail)
|
switch(ev->detail)
|
||||||
{
|
{
|
||||||
|
@ -507,9 +503,12 @@ event_handle_focusin(void *data __attribute__ ((unused)),
|
||||||
*/
|
*/
|
||||||
case XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL:
|
case XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL:
|
||||||
case XCB_NOTIFY_DETAIL_NONLINEAR:
|
case XCB_NOTIFY_DETAIL_NONLINEAR:
|
||||||
if((c = client_getbytitlebarwin(ev->event))
|
{
|
||||||
|| (c = client_getbywin(ev->event)))
|
client_t *c;
|
||||||
|
|
||||||
|
if((c = client_getbywin(ev->event)))
|
||||||
client_focus_update(c);
|
client_focus_update(c);
|
||||||
|
}
|
||||||
/* all other events are ignored */
|
/* all other events are ignored */
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -11,7 +11,6 @@ require("awful.placement")
|
||||||
require("awful.prompt")
|
require("awful.prompt")
|
||||||
require("awful.screen")
|
require("awful.screen")
|
||||||
require("awful.tag")
|
require("awful.tag")
|
||||||
require("awful.titlebar")
|
|
||||||
require("awful.util")
|
require("awful.util")
|
||||||
require("awful.widget")
|
require("awful.widget")
|
||||||
require("awful.menu")
|
require("awful.menu")
|
||||||
|
|
|
@ -105,7 +105,6 @@ capi.client.add_signal("new", function(c)
|
||||||
c:add_signal("property::maximized_vertical", arrange_prop)
|
c:add_signal("property::maximized_vertical", arrange_prop)
|
||||||
c:add_signal("property::border_width", arrange_prop)
|
c:add_signal("property::border_width", arrange_prop)
|
||||||
c:add_signal("property::hidden", arrange_prop)
|
c:add_signal("property::hidden", arrange_prop)
|
||||||
c:add_signal("property::titlebar", arrange_prop)
|
|
||||||
c:add_signal("property::floating", arrange_prop)
|
c:add_signal("property::floating", arrange_prop)
|
||||||
c:add_signal("property::geometry", arrange_prop)
|
c:add_signal("property::geometry", arrange_prop)
|
||||||
-- If prop is screen, we do not know what was the previous screen, so
|
-- If prop is screen, we do not know what was the previous screen, so
|
||||||
|
|
|
@ -1,422 +0,0 @@
|
||||||
---------------------------------------------------------------------------
|
|
||||||
-- @author Julien Danjou <julien@danjou.info>
|
|
||||||
-- @copyright 2008 Julien Danjou
|
|
||||||
-- @release @AWESOME_VERSION@
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Grab environment we need
|
|
||||||
local math = math
|
|
||||||
local image = image
|
|
||||||
local pairs = pairs
|
|
||||||
local type = type
|
|
||||||
local setmetatable = setmetatable
|
|
||||||
local type = type
|
|
||||||
local capi =
|
|
||||||
{
|
|
||||||
awesome = awesome,
|
|
||||||
wibox = wibox,
|
|
||||||
widget = widget,
|
|
||||||
client = client,
|
|
||||||
}
|
|
||||||
local abutton = require("awful.button")
|
|
||||||
local beautiful = require("beautiful")
|
|
||||||
local util = require("awful.util")
|
|
||||||
local widget = require("awful.widget")
|
|
||||||
local mouse = require("awful.mouse")
|
|
||||||
local client = require("awful.client")
|
|
||||||
local layout = require("awful.widget.layout")
|
|
||||||
|
|
||||||
--- Titlebar module for awful
|
|
||||||
module("awful.titlebar")
|
|
||||||
|
|
||||||
-- Privata data
|
|
||||||
local data = setmetatable({}, { __mode = 'k' })
|
|
||||||
|
|
||||||
-- Predeclaration for buttons
|
|
||||||
local button_groups
|
|
||||||
|
|
||||||
local function button_callback_focus_raise_move(w, t)
|
|
||||||
capi.client.focus = t.client
|
|
||||||
t.client:raise()
|
|
||||||
mouse.client.move(t.client)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function button_callback_move(w, t)
|
|
||||||
return mouse.client.move(t.client)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function button_callback_resize(w, t)
|
|
||||||
return mouse.client.resize(t.client)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Create a standard titlebar.
|
|
||||||
-- @param c The client.
|
|
||||||
-- @param args Arguments.
|
|
||||||
-- modkey: the modkey used for the bindings.
|
|
||||||
-- fg: the foreground color.
|
|
||||||
-- bg: the background color.
|
|
||||||
-- fg_focus: the foreground color for focused window.
|
|
||||||
-- fg_focus: the background color for focused window.
|
|
||||||
-- width: the titlebar width
|
|
||||||
function add(c, args)
|
|
||||||
if not c or (c.type ~= "normal" and c.type ~= "dialog") then return end
|
|
||||||
if not args then args = {} end
|
|
||||||
if not args.height then args.height = capi.awesome.font_height * 1.5 end
|
|
||||||
local theme = beautiful.get()
|
|
||||||
if not args.widget then customwidget = {} else customwidget = args.widget end
|
|
||||||
-- Store colors
|
|
||||||
data[c] = {}
|
|
||||||
data[c].fg = args.fg or theme.titlebar_fg_normal or theme.fg_normal
|
|
||||||
data[c].bg = args.bg or theme.titlebar_bg_normal or theme.bg_normal
|
|
||||||
data[c].fg_focus = args.fg_focus or theme.titlebar_fg_focus or theme.fg_focus
|
|
||||||
data[c].bg_focus = args.bg_focus or theme.titlebar_bg_focus or theme.bg_focus
|
|
||||||
data[c].width = args.width
|
|
||||||
data[c].font = args.font or theme.titlebar_font or theme.font
|
|
||||||
|
|
||||||
local tb = capi.wibox(args)
|
|
||||||
|
|
||||||
local title = capi.widget({ type = "textbox" })
|
|
||||||
if c.name then
|
|
||||||
title.text = "<span font_desc='" .. data[c].font .. "'> " ..
|
|
||||||
util.escape(c.name) .. " </span>"
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Redirect relevant events to the client the titlebar belongs to
|
|
||||||
local bts = util.table.join(
|
|
||||||
abutton({ }, 1, button_callback_focus_raise_move),
|
|
||||||
abutton({ args.modkey }, 1, button_callback_move),
|
|
||||||
abutton({ args.modkey }, 3, button_callback_resize))
|
|
||||||
title:buttons(bts)
|
|
||||||
|
|
||||||
local appicon = capi.widget({ type = "imagebox" })
|
|
||||||
appicon.image = c.icon
|
|
||||||
|
|
||||||
-- for each button group, call create for the client.
|
|
||||||
-- if a button set is created add the set to the
|
|
||||||
-- data[c].button_sets for late updates and add the
|
|
||||||
-- individual buttons to the array part of the widget
|
|
||||||
-- list
|
|
||||||
local widget_list = {
|
|
||||||
layout = layout.horizontal.rightleft
|
|
||||||
}
|
|
||||||
local iw = 1
|
|
||||||
local is = 1
|
|
||||||
data[c].button_sets = {}
|
|
||||||
for i = 1, #button_groups do
|
|
||||||
local set = button_groups[i].create(c, args.modkey, theme)
|
|
||||||
if (set) then
|
|
||||||
data[c].button_sets[is] = set
|
|
||||||
is = is + 1
|
|
||||||
for n,b in pairs(set) do
|
|
||||||
widget_list[iw] = b
|
|
||||||
iw = iw + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
tb.widgets = {
|
|
||||||
widget_list,
|
|
||||||
customwidget,
|
|
||||||
{
|
|
||||||
appicon = appicon,
|
|
||||||
title = title,
|
|
||||||
layout = layout.horizontal.flex
|
|
||||||
},
|
|
||||||
layout = layout.horizontal.rightleft
|
|
||||||
}
|
|
||||||
|
|
||||||
c.titlebar = tb
|
|
||||||
|
|
||||||
c:add_signal("property::icon", update)
|
|
||||||
c:add_signal("property::name", update)
|
|
||||||
c:add_signal("property::sticky", update)
|
|
||||||
c:add_signal("property::floating", update)
|
|
||||||
c:add_signal("property::ontop", update)
|
|
||||||
c:add_signal("property::maximized_vertical", update)
|
|
||||||
c:add_signal("property::maximized_horizontal", update)
|
|
||||||
update(c)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Update a titlebar. This should be called in some hooks.
|
|
||||||
-- @param c The client to update.
|
|
||||||
-- @param prop The property name which has changed.
|
|
||||||
function update(c)
|
|
||||||
if c.titlebar and data[c] then
|
|
||||||
local widgets = c.titlebar.widgets
|
|
||||||
if widgets[3].title then
|
|
||||||
widgets[3].title.text = "<span font_desc='" .. data[c].font ..
|
|
||||||
"'> ".. util.escape(c.name or "<unknown>") .. " </span>"
|
|
||||||
end
|
|
||||||
if widgets[3].appicon then
|
|
||||||
widgets[3].appicon.image = c.icon
|
|
||||||
end
|
|
||||||
if capi.client.focus == c then
|
|
||||||
c.titlebar.fg = data[c].fg_focus
|
|
||||||
c.titlebar.bg = data[c].bg_focus
|
|
||||||
else
|
|
||||||
c.titlebar.fg = data[c].fg
|
|
||||||
c.titlebar.bg = data[c].bg
|
|
||||||
end
|
|
||||||
|
|
||||||
-- iterated of all registered button_sets and update
|
|
||||||
local sets = data[c].button_sets
|
|
||||||
for i = 1, #sets do
|
|
||||||
sets[i].update(c,prop)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Remove a titlebar from a client.
|
|
||||||
-- @param c The client.
|
|
||||||
function remove(c)
|
|
||||||
c.titlebar = nil
|
|
||||||
data[c] = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Create a new button for the toolbar
|
|
||||||
-- @param c The client of the titlebar
|
|
||||||
-- @param name The base name of the button (i.e. close)
|
|
||||||
-- @param modkey ... you know that one, don't you?
|
|
||||||
-- @param theme The theme from beautifull. Used to get the image paths
|
|
||||||
-- @param state The state the button is associated to. Containse path the action and info about the image
|
|
||||||
local function button_new(c, name, modkey, theme, state)
|
|
||||||
local bts = abutton({ }, 1, nil, state.action)
|
|
||||||
|
|
||||||
-- get the image path from the theme. Only return a button if we find an image
|
|
||||||
local img
|
|
||||||
img = "titlebar_" .. name .. "_button_" .. state.img
|
|
||||||
img = theme[img]
|
|
||||||
if not img then return end
|
|
||||||
img = image(img)
|
|
||||||
if not img then return end
|
|
||||||
|
|
||||||
-- now create the button
|
|
||||||
local bname = name .. "_" .. state.idx
|
|
||||||
local button = widget.button({ image = img })
|
|
||||||
if not button then return end
|
|
||||||
local rbts = button:buttons()
|
|
||||||
|
|
||||||
for k, v in pairs(rbts) do
|
|
||||||
bts[#bts + 1] = v
|
|
||||||
end
|
|
||||||
|
|
||||||
button:buttons(bts)
|
|
||||||
button.visible = false
|
|
||||||
return button
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Update the buttons in a button group
|
|
||||||
-- @param s The button group to update
|
|
||||||
-- @param c The client of the titlebar
|
|
||||||
-- @param p The property that has changed
|
|
||||||
local function button_group_update(s,c,p)
|
|
||||||
-- hide the currently active button, get the new state and show the new button
|
|
||||||
local n = s.select_state(c,p)
|
|
||||||
if n == nil then return end
|
|
||||||
if (s.active ~= nil) then s.active.visible = false end
|
|
||||||
s.active = s.buttons[n]
|
|
||||||
s.active.visible = true
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Create all buttons in a group
|
|
||||||
-- @param c The client of the titlebar
|
|
||||||
-- @param group The button group to create the buttons for
|
|
||||||
-- @param modkey ...
|
|
||||||
-- @param theme Theme for the image paths
|
|
||||||
local function button_group_create(c, group, modkey, theme )
|
|
||||||
local s = {}
|
|
||||||
s.name = group.name
|
|
||||||
s.select_state = group.select_state
|
|
||||||
s.buttons = {
|
|
||||||
layout = layout.horizontal.rightleft
|
|
||||||
}
|
|
||||||
for n,state in pairs(group.states) do
|
|
||||||
s.buttons[n] = button_new(c, s.name, modkey, theme, state)
|
|
||||||
if (s.buttons[n] == nil) then return end
|
|
||||||
for a,v in pairs(group.attributes) do
|
|
||||||
s.buttons[n][a] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
function s.update(c,p) button_group_update(s,c,p) end
|
|
||||||
return s
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Builds a new button group
|
|
||||||
-- @param name The base name for the buttons in the group (i.e. "close")
|
|
||||||
-- @param attrs Common attributes for the buttons (i.e. {align = "right")
|
|
||||||
-- @param sfn State select function.
|
|
||||||
-- @param args The states of the button
|
|
||||||
local function button_group(name, attrs, sfn, ...)
|
|
||||||
local s = {}
|
|
||||||
s.name = name
|
|
||||||
s.select_state = sfn
|
|
||||||
s.attributes = attrs
|
|
||||||
s.states = {}
|
|
||||||
|
|
||||||
for i = 1, #arg do
|
|
||||||
local state = arg[i]
|
|
||||||
s.states[state.idx] = state
|
|
||||||
end
|
|
||||||
|
|
||||||
function s.create(c,modkey, theme) return button_group_create(c,s,modkey, theme) end
|
|
||||||
return s
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Select a state for a client based on an attribute of the client and whether it has focus
|
|
||||||
-- @param c The client of the titlebar
|
|
||||||
-- @param p The property that has changed
|
|
||||||
-- @param a The property to check
|
|
||||||
local function select_state(c,p,a)
|
|
||||||
if (c == nil) then return "n/i" end
|
|
||||||
if capi.client.focus == c then
|
|
||||||
if c[a] then
|
|
||||||
return "f/a"
|
|
||||||
else
|
|
||||||
return "f/i"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if c[a] then
|
|
||||||
return "n/a"
|
|
||||||
else
|
|
||||||
return "n/i"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Select a state for a client based on whether it's floating or not
|
|
||||||
-- @param c The client of the titlebar
|
|
||||||
-- @param p The property that has changed
|
|
||||||
local function select_state_floating(c,p)
|
|
||||||
if not c then return end
|
|
||||||
if capi.client.focus == c then
|
|
||||||
if client.floating.get(c) then
|
|
||||||
return "f/a"
|
|
||||||
end
|
|
||||||
return "f/i"
|
|
||||||
end
|
|
||||||
if client.floating.get(c) then
|
|
||||||
return "n/a"
|
|
||||||
end
|
|
||||||
return "n/i"
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Select a state for a client based on whether it's maximized or not
|
|
||||||
-- @param c The client of the titlebar
|
|
||||||
-- @param p The property that has changed
|
|
||||||
local function select_state_maximized(c,p)
|
|
||||||
if (c == nil) then return "n/i" end
|
|
||||||
if capi.client.focus == c then
|
|
||||||
if c.maximized_horizontal or c.maximized_vertical then
|
|
||||||
return "f/a"
|
|
||||||
else
|
|
||||||
return "f/i"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if c.maximized_horizontal or c.maximized_vertical then
|
|
||||||
return "n/a"
|
|
||||||
else
|
|
||||||
return "n/i"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Select a state for a client based on whether it has focus or not
|
|
||||||
-- @param c The client of the titlebar
|
|
||||||
-- @param p The property that has changed
|
|
||||||
local function select_state_focus(c,p)
|
|
||||||
if c and capi.client.focus == c then
|
|
||||||
return "f"
|
|
||||||
end
|
|
||||||
return "n"
|
|
||||||
end
|
|
||||||
|
|
||||||
-- These are the predefined button groups
|
|
||||||
-- A short explanation using 'close_buttons' as an example:
|
|
||||||
-- "close" : name of the button, the images for this button are taken from the
|
|
||||||
-- theme variables titlebar_close_button_...
|
|
||||||
-- { align ... : attributes of all the buttons
|
|
||||||
-- select_state_focus : This function returns a short string used to describe
|
|
||||||
-- the state. In this case either "n" or "f" depending on
|
|
||||||
-- the focus state of the client. These strings can be
|
|
||||||
-- choosen freely but the< must match one of the idx fuekds
|
|
||||||
-- of the states below
|
|
||||||
-- { idx = "n" ... : This is the state of the button for the 'unfocussed'
|
|
||||||
-- (normal) state. The idx = "n" parameter connects this
|
|
||||||
-- button to the return value of the 'select_state_focus'
|
|
||||||
-- function. The img = "normal" parameter is used to
|
|
||||||
-- determine its image. In this case the iamge is taken from
|
|
||||||
-- the theme variable "titlebar_close_button_normal".
|
|
||||||
-- Finally the last parameter is the action for mouse
|
|
||||||
-- button 1
|
|
||||||
|
|
||||||
local ontop_buttons = button_group("ontop",
|
|
||||||
{ align = "right" },
|
|
||||||
function(c,p) return select_state(c, p, "ontop") end,
|
|
||||||
{ idx = "n/i", img = "normal_inactive",
|
|
||||||
action = function(w, t) t.client.ontop = true end },
|
|
||||||
{ idx = "f/i", img = "focus_inactive",
|
|
||||||
action = function(w, t) t.client.ontop = true end },
|
|
||||||
{ idx = "n/a", img = "normal_active",
|
|
||||||
action = function(w, t) t.client.ontop = false end },
|
|
||||||
{ idx = "f/a", img = "focus_active",
|
|
||||||
action = function(w, t) t.client.ontop = false end })
|
|
||||||
|
|
||||||
local sticky_buttons = button_group("sticky",
|
|
||||||
{ align = "right" },
|
|
||||||
function(c,p) return select_state(c,p,"sticky") end,
|
|
||||||
{ idx = "n/i", img = "normal_inactive",
|
|
||||||
action = function(w, t) t.client.sticky = true end },
|
|
||||||
{ idx = "f/i", img = "focus_inactive",
|
|
||||||
action = function(w, t) t.client.sticky = true end },
|
|
||||||
{ idx = "n/a", img = "normal_active",
|
|
||||||
action = function(w, t) t.client.sticky = false end },
|
|
||||||
{ idx = "f/a", img = "focus_active",
|
|
||||||
action = function(w, t) t.client.sticky = false end })
|
|
||||||
|
|
||||||
local maximized_buttons = button_group("maximized",
|
|
||||||
{ align = "right" },
|
|
||||||
select_state_maximized,
|
|
||||||
{ idx = "n/i", img = "normal_inactive",
|
|
||||||
action = function(w, t) t.client.maximized_horizontal = true
|
|
||||||
t.client.maximized_vertical = true end },
|
|
||||||
{ idx = "f/i", img = "focus_inactive",
|
|
||||||
action = function(w, t) t.client.maximized_horizontal = true
|
|
||||||
t.client.maximized_vertical = true end },
|
|
||||||
{ idx = "n/a", img = "normal_active",
|
|
||||||
action = function(w, t) t.client.maximized_horizontal = false
|
|
||||||
t.client.maximized_vertical = false end },
|
|
||||||
{ idx = "f/a", img = "focus_active",
|
|
||||||
action = function(w, t) t.client.maximized_horizontal = false
|
|
||||||
t.client.maximized_vertical = false end })
|
|
||||||
|
|
||||||
local close_buttons = button_group("close",
|
|
||||||
{ align = "left" },
|
|
||||||
select_state_focus,
|
|
||||||
{ idx = "n", img = "normal",
|
|
||||||
action = function (w, t) t.client:kill() end },
|
|
||||||
{ idx = "f", img = "focus",
|
|
||||||
action = function (w, t) t.client:kill() end })
|
|
||||||
|
|
||||||
local function floating_update(w, t)
|
|
||||||
client.floating.toggle(t.client)
|
|
||||||
end
|
|
||||||
|
|
||||||
local floating_buttons = button_group("floating",
|
|
||||||
{ align = "right"},
|
|
||||||
select_state_floating,
|
|
||||||
{ idx = "n/i", img = "normal_inactive", action = floating_update },
|
|
||||||
{ idx = "f/i", img = "focus_inactive", action = floating_update },
|
|
||||||
{ idx = "n/a", img = "normal_active", action = floating_update },
|
|
||||||
{ idx = "f/a", img = "focus_active", action = floating_update })
|
|
||||||
|
|
||||||
button_groups = { close_buttons,
|
|
||||||
ontop_buttons,
|
|
||||||
sticky_buttons,
|
|
||||||
maximized_buttons,
|
|
||||||
floating_buttons }
|
|
||||||
|
|
||||||
-- Register standards hooks
|
|
||||||
capi.client.add_signal("focus", update)
|
|
||||||
capi.client.add_signal("unfocus", update)
|
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
|
3
luaa.c
3
luaa.c
|
@ -603,9 +603,6 @@ luaA_awesome_newindex(lua_State *L)
|
||||||
/* refresh all wiboxes */
|
/* refresh all wiboxes */
|
||||||
foreach(wibox, globalconf.wiboxes)
|
foreach(wibox, globalconf.wiboxes)
|
||||||
(*wibox)->need_update = true;
|
(*wibox)->need_update = true;
|
||||||
foreach(c, globalconf.clients)
|
|
||||||
if((*c)->titlebar)
|
|
||||||
(*c)->titlebar->need_update = true;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case A_TK_FG:
|
case A_TK_FG:
|
||||||
|
|
|
@ -23,7 +23,6 @@ module("client")
|
||||||
-- @field size_hints_honor Honor size hints, i.e. respect size ratio.
|
-- @field size_hints_honor Honor size hints, i.e. respect size ratio.
|
||||||
-- @field border_width The client border width.
|
-- @field border_width The client border width.
|
||||||
-- @field border_color The client border color.
|
-- @field border_color The client border color.
|
||||||
-- @field titlebar The client titlebar.
|
|
||||||
-- @field urgent The client urgent state.
|
-- @field urgent The client urgent state.
|
||||||
-- @field content An image representing the client window content (screenshot).
|
-- @field content An image representing the client window content (screenshot).
|
||||||
-- @field focus The focused client.
|
-- @field focus The focused client.
|
||||||
|
|
|
@ -5,14 +5,11 @@ module("wibox")
|
||||||
|
|
||||||
--- Wibox object.
|
--- Wibox object.
|
||||||
-- @field screen Screen number.
|
-- @field screen Screen number.
|
||||||
-- @field client The client attached to (titlebar only).
|
|
||||||
-- @field border_width Border width.
|
-- @field border_width Border width.
|
||||||
-- @field border_color Border color.
|
-- @field border_color Border color.
|
||||||
-- @field align The alignment (titlebar only).
|
|
||||||
-- @field fg Foreground color.
|
-- @field fg Foreground color.
|
||||||
-- @field bg Background color.
|
-- @field bg Background color.
|
||||||
-- @field bg_image Background image.
|
-- @field bg_image Background image.
|
||||||
-- @field position The position (titlebar only).
|
|
||||||
-- @field ontop On top of other windows.
|
-- @field ontop On top of other windows.
|
||||||
-- @field cursor The mouse cursor.
|
-- @field cursor The mouse cursor.
|
||||||
-- @field visible Visibility.
|
-- @field visible Visibility.
|
||||||
|
|
|
@ -25,11 +25,12 @@
|
||||||
#include "objects/tag.h"
|
#include "objects/tag.h"
|
||||||
#include "ewmh.h"
|
#include "ewmh.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "titlebar.h"
|
#include "wibox.h"
|
||||||
#include "systray.h"
|
#include "systray.h"
|
||||||
#include "property.h"
|
#include "property.h"
|
||||||
#include "spawn.h"
|
#include "spawn.h"
|
||||||
#include "luaa.h"
|
#include "luaa.h"
|
||||||
|
#include "window.h"
|
||||||
#include "common/atoms.h"
|
#include "common/atoms.h"
|
||||||
#include "common/xutil.h"
|
#include "common/xutil.h"
|
||||||
|
|
||||||
|
@ -452,18 +453,7 @@ client_stack_above(client_t *c, xcb_window_t previous)
|
||||||
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
||||||
config_win_vals);
|
config_win_vals);
|
||||||
|
|
||||||
config_win_vals[0] = c->window;
|
previous = config_win_vals[0] = c->window;
|
||||||
|
|
||||||
if(c->titlebar)
|
|
||||||
{
|
|
||||||
xcb_configure_window(globalconf.connection,
|
|
||||||
c->titlebar->window,
|
|
||||||
XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE,
|
|
||||||
config_win_vals);
|
|
||||||
previous = c->titlebar->window;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
previous = c->window;
|
|
||||||
|
|
||||||
/* stack transient window on top of their parents */
|
/* stack transient window on top of their parents */
|
||||||
foreach(node, globalconf.stack)
|
foreach(node, globalconf.stack)
|
||||||
|
@ -811,7 +801,7 @@ client_geometry_hints(client_t *c, area_t geometry)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resize client window.
|
/** Resize client window.
|
||||||
* The sizes given as parameters are with titlebar and borders!
|
* The sizes given as parameters are with borders!
|
||||||
* \param c Client to resize.
|
* \param c Client to resize.
|
||||||
* \param geometry New window geometry.
|
* \param geometry New window geometry.
|
||||||
* \param hints Use size hints.
|
* \param hints Use size hints.
|
||||||
|
@ -820,7 +810,6 @@ client_geometry_hints(client_t *c, area_t geometry)
|
||||||
bool
|
bool
|
||||||
client_resize(client_t *c, area_t geometry, bool hints)
|
client_resize(client_t *c, area_t geometry, bool hints)
|
||||||
{
|
{
|
||||||
area_t geometry_internal;
|
|
||||||
area_t area;
|
area_t area;
|
||||||
|
|
||||||
/* offscreen appearance fixes */
|
/* offscreen appearance fixes */
|
||||||
|
@ -835,8 +824,10 @@ client_resize(client_t *c, area_t geometry, bool hints)
|
||||||
if(geometry.y + geometry.height < 0)
|
if(geometry.y + geometry.height < 0)
|
||||||
geometry.y = 0;
|
geometry.y = 0;
|
||||||
|
|
||||||
/* Real client geometry, please keep it contained to C code at the very least. */
|
area_t geometry_internal = { .x = geometry.x,
|
||||||
geometry_internal = titlebar_geometry_remove(c->titlebar, c->border_width, geometry);
|
.y = geometry.y,
|
||||||
|
.width = geometry.width - 2 * c->border_width,
|
||||||
|
.height = geometry.height - 2 * c->border_width };
|
||||||
|
|
||||||
if(hints)
|
if(hints)
|
||||||
geometry_internal = client_geometry_hints(c, geometry_internal);
|
geometry_internal = client_geometry_hints(c, geometry_internal);
|
||||||
|
@ -845,7 +836,10 @@ client_resize(client_t *c, area_t geometry, bool hints)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Also let client hints propagate to the "official" geometry. */
|
/* Also let client hints propagate to the "official" geometry. */
|
||||||
geometry = titlebar_geometry_add(c->titlebar, c->border_width, geometry_internal);
|
geometry.x = geometry_internal.x;
|
||||||
|
geometry.y = geometry_internal.y;
|
||||||
|
geometry.width = geometry_internal.width + 2 * c->border_width;
|
||||||
|
geometry.height = geometry_internal.height + 2 * c->border_width;
|
||||||
|
|
||||||
if(c->geometries.internal.x != geometry_internal.x
|
if(c->geometries.internal.x != geometry_internal.x
|
||||||
|| c->geometries.internal.y != geometry_internal.y
|
|| c->geometries.internal.y != geometry_internal.y
|
||||||
|
@ -864,11 +858,9 @@ client_resize(client_t *c, area_t geometry, bool hints)
|
||||||
c->geometries.internal.width = values[2] = geometry_internal.width;
|
c->geometries.internal.width = values[2] = geometry_internal.width;
|
||||||
c->geometries.internal.height = values[3] = geometry_internal.height;
|
c->geometries.internal.height = values[3] = geometry_internal.height;
|
||||||
|
|
||||||
/* Also store geometry including border and titlebar. */
|
/* Also store geometry including border */
|
||||||
c->geometry = geometry;
|
c->geometry = geometry;
|
||||||
|
|
||||||
titlebar_update_geometry(c);
|
|
||||||
|
|
||||||
/* Ignore all spurious enter/leave notify events */
|
/* Ignore all spurious enter/leave notify events */
|
||||||
client_ignore_enterleave_events();
|
client_ignore_enterleave_events();
|
||||||
|
|
||||||
|
@ -957,8 +949,6 @@ client_set_fullscreen(lua_State *L, int cidx, bool s)
|
||||||
/* become fullscreen! */
|
/* become fullscreen! */
|
||||||
if(s)
|
if(s)
|
||||||
{
|
{
|
||||||
/* Make sure the current geometry is stored without titlebar. */
|
|
||||||
titlebar_ban(c->titlebar);
|
|
||||||
/* remove any max state */
|
/* remove any max state */
|
||||||
client_set_maximized_horizontal(L, cidx, false);
|
client_set_maximized_horizontal(L, cidx, false);
|
||||||
client_set_maximized_vertical(L, cidx, false);
|
client_set_maximized_vertical(L, cidx, false);
|
||||||
|
@ -1235,8 +1225,6 @@ client_unmanage(client_t *c)
|
||||||
|
|
||||||
window_state_set(c->window, XCB_WM_STATE_WITHDRAWN);
|
window_state_set(c->window, XCB_WM_STATE_WITHDRAWN);
|
||||||
|
|
||||||
titlebar_client_detach(c);
|
|
||||||
|
|
||||||
ewmh_update_net_client_list(c->phys_screen);
|
ewmh_update_net_client_list(c->phys_screen);
|
||||||
|
|
||||||
/* set client as invalid */
|
/* set client as invalid */
|
||||||
|
@ -1359,9 +1347,6 @@ client_set_border_width(lua_State *L, int cidx, int width)
|
||||||
c->geometry.width += 2 * c->border_width;
|
c->geometry.width += 2 * c->border_width;
|
||||||
c->geometry.height += 2 * c->border_width;
|
c->geometry.height += 2 * c->border_width;
|
||||||
|
|
||||||
/* Changing border size also affects the size of the titlebar. */
|
|
||||||
titlebar_update_geometry(c);
|
|
||||||
|
|
||||||
luaA_object_emit_signal(L, cidx, "property::border_width", 0);
|
luaA_object_emit_signal(L, cidx, "property::border_width", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1743,16 +1728,6 @@ luaA_client_set_border_color(lua_State *L, client_t *c)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
luaA_client_set_titlebar(lua_State *L, client_t *c)
|
|
||||||
{
|
|
||||||
if(lua_isnil(L, -1))
|
|
||||||
titlebar_client_detach(c);
|
|
||||||
else
|
|
||||||
titlebar_client_attach(c);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
luaA_client_set_skip_taskbar(lua_State *L, client_t *c)
|
luaA_client_set_skip_taskbar(lua_State *L, client_t *c)
|
||||||
{
|
{
|
||||||
|
@ -1898,12 +1873,6 @@ luaA_client_get_icon(lua_State *L, client_t *c)
|
||||||
return luaA_object_push_item(L, -2, c->icon);
|
return luaA_object_push_item(L, -2, c->icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
luaA_client_get_titlebar(lua_State *L, client_t *c)
|
|
||||||
{
|
|
||||||
return luaA_object_push(L, c->titlebar);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
luaA_client_get_size_hints(lua_State *L, client_t *c)
|
luaA_client_get_size_hints(lua_State *L, client_t *c)
|
||||||
{
|
{
|
||||||
|
@ -2275,10 +2244,6 @@ client_class_setup(lua_State *L)
|
||||||
(lua_class_propfunc_t) luaA_client_set_border_color,
|
(lua_class_propfunc_t) luaA_client_set_border_color,
|
||||||
(lua_class_propfunc_t) luaA_client_get_border_color,
|
(lua_class_propfunc_t) luaA_client_get_border_color,
|
||||||
(lua_class_propfunc_t) luaA_client_set_border_color);
|
(lua_class_propfunc_t) luaA_client_set_border_color);
|
||||||
luaA_class_add_property(&client_class, A_TK_TITLEBAR,
|
|
||||||
(lua_class_propfunc_t) luaA_client_set_titlebar,
|
|
||||||
(lua_class_propfunc_t) luaA_client_get_titlebar,
|
|
||||||
(lua_class_propfunc_t) luaA_client_set_titlebar);
|
|
||||||
luaA_class_add_property(&client_class, A_TK_URGENT,
|
luaA_class_add_property(&client_class, A_TK_URGENT,
|
||||||
(lua_class_propfunc_t) luaA_client_set_urgent,
|
(lua_class_propfunc_t) luaA_client_set_urgent,
|
||||||
(lua_class_propfunc_t) luaA_client_get_urgent,
|
(lua_class_propfunc_t) luaA_client_get_urgent,
|
||||||
|
|
|
@ -128,8 +128,6 @@ struct client_t
|
||||||
screen_t *screen;
|
screen_t *screen;
|
||||||
/** Client physical screen */
|
/** Client physical screen */
|
||||||
int phys_screen;
|
int phys_screen;
|
||||||
/** Titlebar */
|
|
||||||
wibox_t *titlebar;
|
|
||||||
/** Button bindings */
|
/** Button bindings */
|
||||||
button_array_t buttons;
|
button_array_t buttons;
|
||||||
/** Key bindings */
|
/** Key bindings */
|
||||||
|
|
226
objects/wibox.c
226
objects/wibox.c
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "wibox.h"
|
#include "wibox.h"
|
||||||
#include "titlebar.h"
|
|
||||||
#include "objects/client.h"
|
#include "objects/client.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
@ -34,6 +33,34 @@
|
||||||
|
|
||||||
LUA_OBJECT_FUNCS(wibox_class, wibox_t, wibox)
|
LUA_OBJECT_FUNCS(wibox_class, wibox_t, wibox)
|
||||||
|
|
||||||
|
/** Destroy all X resources of a wibox.
|
||||||
|
* \param w The wibox to wipe.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
wibox_wipe(wibox_t *w)
|
||||||
|
{
|
||||||
|
if(w->window)
|
||||||
|
{
|
||||||
|
/* Activate BMA */
|
||||||
|
client_ignore_enterleave_events();
|
||||||
|
xcb_destroy_window(globalconf.connection, w->window);
|
||||||
|
/* Deactivate BMA */
|
||||||
|
client_restore_enterleave_events();
|
||||||
|
w->window = XCB_NONE;
|
||||||
|
}
|
||||||
|
if(w->pixmap)
|
||||||
|
{
|
||||||
|
xcb_free_pixmap(globalconf.connection, w->pixmap);
|
||||||
|
w->pixmap = XCB_NONE;
|
||||||
|
}
|
||||||
|
if(w->gc)
|
||||||
|
{
|
||||||
|
xcb_free_gc(globalconf.connection, w->gc);
|
||||||
|
w->gc = XCB_NONE;
|
||||||
|
}
|
||||||
|
draw_context_wipe(&w->ctx);
|
||||||
|
}
|
||||||
|
|
||||||
/** Take care of garbage collecting a wibox.
|
/** Take care of garbage collecting a wibox.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
* \return The number of elements pushed on stack, 0!
|
* \return The number of elements pushed on stack, 0!
|
||||||
|
@ -156,7 +183,7 @@ wibox_draw_context_update(wibox_t *w, xcb_screen_t *s)
|
||||||
* \param w The wibox to initialize.
|
* \param w The wibox to initialize.
|
||||||
* \param phys_screen Physical screen number.
|
* \param phys_screen Physical screen number.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
wibox_init(wibox_t *w, int phys_screen)
|
wibox_init(wibox_t *w, 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);
|
||||||
|
@ -212,7 +239,7 @@ wibox_refresh_pixmap(wibox_t *w)
|
||||||
* \param udx The index of the wibox.
|
* \param udx The index of the wibox.
|
||||||
* \param geometry The new geometry.
|
* \param geometry The new geometry.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
wibox_moveresize(lua_State *L, int udx, area_t geometry)
|
wibox_moveresize(lua_State *L, int udx, area_t geometry)
|
||||||
{
|
{
|
||||||
wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
|
wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
|
||||||
|
@ -346,7 +373,7 @@ wibox_set_border_color(lua_State *L, int udx, const xcolor_t *color)
|
||||||
* \param udx The wibox to change orientation.
|
* \param udx The wibox to change orientation.
|
||||||
* \param o The new orientation.
|
* \param o The new orientation.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
wibox_set_orientation(lua_State *L, int udx, orientation_t o)
|
wibox_set_orientation(lua_State *L, int udx, orientation_t o)
|
||||||
{
|
{
|
||||||
wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
|
wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
|
||||||
|
@ -568,14 +595,6 @@ wibox_getbywin(xcb_window_t win)
|
||||||
foreach(w, globalconf.wiboxes)
|
foreach(w, globalconf.wiboxes)
|
||||||
if((*w)->window == win)
|
if((*w)->window == win)
|
||||||
return *w;
|
return *w;
|
||||||
|
|
||||||
foreach(_c, globalconf.clients)
|
|
||||||
{
|
|
||||||
client_t *c = *_c;
|
|
||||||
if(c->titlebar && c->titlebar->window == win)
|
|
||||||
return c->titlebar;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,13 +627,6 @@ wibox_refresh(void)
|
||||||
if((*w)->need_update)
|
if((*w)->need_update)
|
||||||
wibox_draw(*w);
|
wibox_draw(*w);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(_c, globalconf.clients)
|
|
||||||
{
|
|
||||||
client_t *c = *_c;
|
|
||||||
if(c->titlebar && c->titlebar->need_update)
|
|
||||||
wibox_draw(c->titlebar);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set a wibox visible or not.
|
/** Set a wibox visible or not.
|
||||||
|
@ -653,34 +665,6 @@ wibox_set_visible(lua_State *L, int udx, bool v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Destroy all X resources of a wibox.
|
|
||||||
* \param w The wibox to wipe.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
wibox_wipe(wibox_t *w)
|
|
||||||
{
|
|
||||||
if(w->window)
|
|
||||||
{
|
|
||||||
/* Activate BMA */
|
|
||||||
client_ignore_enterleave_events();
|
|
||||||
xcb_destroy_window(globalconf.connection, w->window);
|
|
||||||
/* Deactivate BMA */
|
|
||||||
client_restore_enterleave_events();
|
|
||||||
w->window = XCB_NONE;
|
|
||||||
}
|
|
||||||
if(w->pixmap)
|
|
||||||
{
|
|
||||||
xcb_free_pixmap(globalconf.connection, w->pixmap);
|
|
||||||
w->pixmap = XCB_NONE;
|
|
||||||
}
|
|
||||||
if(w->gc)
|
|
||||||
{
|
|
||||||
xcb_free_gc(globalconf.connection, w->gc);
|
|
||||||
w->gc = XCB_NONE;
|
|
||||||
}
|
|
||||||
draw_context_wipe(&w->ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Remove a wibox from a screen.
|
/** Remove a wibox from a screen.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
* \param udx Wibox to detach from screen.
|
* \param udx Wibox to detach from screen.
|
||||||
|
@ -853,17 +837,6 @@ luaA_wibox_invalidate_byitem(lua_State *L, const void *item)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(_c, globalconf.clients)
|
|
||||||
{
|
|
||||||
client_t *c = *_c;
|
|
||||||
if(c->titlebar && luaA_wibox_hasitem(L, c->titlebar, item))
|
|
||||||
{
|
|
||||||
/* update wibox */
|
|
||||||
wibox_need_update(c->titlebar);
|
|
||||||
lua_pop(L, 1); /* remove widgets table */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set or get the wibox geometry.
|
/* Set or get the wibox geometry.
|
||||||
|
@ -889,18 +862,7 @@ luaA_wibox_geometry(lua_State *L)
|
||||||
wingeom.height = luaA_getopt_number(L, 2, "height", wibox->geometry.height);
|
wingeom.height = luaA_getopt_number(L, 2, "height", wibox->geometry.height);
|
||||||
|
|
||||||
if(wingeom.width > 0 && wingeom.height > 0)
|
if(wingeom.width > 0 && wingeom.height > 0)
|
||||||
switch(wibox->type)
|
|
||||||
{
|
|
||||||
case WIBOX_TYPE_TITLEBAR:
|
|
||||||
wibox_moveresize(L, 1, (area_t) { .x = wibox->geometry.x,
|
|
||||||
.y = wibox->geometry.y,
|
|
||||||
.width = wingeom.width,
|
|
||||||
.height = wingeom.height });
|
|
||||||
break;
|
|
||||||
case WIBOX_TYPE_NORMAL:
|
|
||||||
wibox_moveresize(L, 1, wingeom);
|
wibox_moveresize(L, 1, wingeom);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return luaA_pusharea(L, wibox->geometry);
|
return luaA_pusharea(L, wibox->geometry);
|
||||||
|
@ -1138,102 +1100,6 @@ luaA_wibox_get_opacity(lua_State *L, wibox_t *wibox)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set the wibox alignment.
|
|
||||||
* \param L The Lua VM state.
|
|
||||||
* \param wibox The wibox object.
|
|
||||||
* \return The number of elements pushed on stack.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
luaA_wibox_set_align(lua_State *L, wibox_t *wibox)
|
|
||||||
{
|
|
||||||
size_t len;
|
|
||||||
const char *buf = luaL_checklstring(L, -1, &len);
|
|
||||||
wibox->align = draw_align_fromstr(buf, len);
|
|
||||||
luaA_object_emit_signal(L, -3, "property::align", 0);
|
|
||||||
switch(wibox->type)
|
|
||||||
{
|
|
||||||
case WIBOX_TYPE_NORMAL:
|
|
||||||
break;
|
|
||||||
case WIBOX_TYPE_TITLEBAR:
|
|
||||||
titlebar_update_geometry(client_getbytitlebar(wibox));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get the wibox alignment.
|
|
||||||
* \param L The Lua VM state.
|
|
||||||
* \param wibox The wibox object.
|
|
||||||
* \return The number of elements pushed on stack.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
luaA_wibox_get_align(lua_State *L, wibox_t *wibox)
|
|
||||||
{
|
|
||||||
lua_pushstring(L, draw_align_tostr(wibox->align));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set the wibox position.
|
|
||||||
* \param L The Lua VM state.
|
|
||||||
* \param wibox The wibox object.
|
|
||||||
* \return The number of elements pushed on stack.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
luaA_wibox_set_position(lua_State *L, wibox_t *wibox)
|
|
||||||
{
|
|
||||||
switch(wibox->type)
|
|
||||||
{
|
|
||||||
case WIBOX_TYPE_NORMAL:
|
|
||||||
break;
|
|
||||||
case WIBOX_TYPE_TITLEBAR:
|
|
||||||
return luaA_titlebar_set_position(L, -3);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get the wibox position.
|
|
||||||
* \param L The Lua VM state.
|
|
||||||
* \param wibox The wibox object.
|
|
||||||
* \return The number of elements pushed on stack.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
luaA_wibox_get_position(lua_State *L, wibox_t *wibox)
|
|
||||||
{
|
|
||||||
lua_pushstring(L, position_tostr(wibox->position));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set the wibox (titlebar) client.
|
|
||||||
* \param L The Lua VM state.
|
|
||||||
* \param wibox The wibox object.
|
|
||||||
* \return The number of elements pushed on stack.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
luaA_wibox_set_client(lua_State *L, wibox_t *wibox)
|
|
||||||
{
|
|
||||||
/* first detach */
|
|
||||||
if(lua_isnil(L, -1))
|
|
||||||
titlebar_client_detach(client_getbytitlebar(wibox));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
client_t *c = luaA_client_checkudata(L, -1);
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
titlebar_client_attach(c);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get the wibox (titlebar) client.
|
|
||||||
* \param L The Lua VM state.
|
|
||||||
* \param wibox The wibox object.
|
|
||||||
* \return The number of elements pushed on stack.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
luaA_wibox_get_client(lua_State *L, wibox_t *wibox)
|
|
||||||
{
|
|
||||||
return luaA_object_push(L, client_getbytitlebar(wibox));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set the wibox cursor.
|
/** Set the wibox cursor.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
* \param wibox The wibox object.
|
* \param wibox The wibox object.
|
||||||
|
@ -1267,20 +1133,14 @@ static int
|
||||||
luaA_wibox_set_screen(lua_State *L, wibox_t *wibox)
|
luaA_wibox_set_screen(lua_State *L, wibox_t *wibox)
|
||||||
{
|
{
|
||||||
if(lua_isnil(L, -1))
|
if(lua_isnil(L, -1))
|
||||||
{
|
|
||||||
wibox_detach(L, -3);
|
wibox_detach(L, -3);
|
||||||
titlebar_client_detach(client_getbytitlebar(wibox));
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int screen = luaL_checknumber(L, -1) - 1;
|
int screen = luaL_checknumber(L, -1) - 1;
|
||||||
luaA_checkscreen(screen);
|
luaA_checkscreen(screen);
|
||||||
if(!wibox->screen || screen != screen_array_indexof(&globalconf.screens, wibox->screen))
|
if(!wibox->screen || screen != screen_array_indexof(&globalconf.screens, wibox->screen))
|
||||||
{
|
|
||||||
titlebar_client_detach(client_getbytitlebar(wibox));
|
|
||||||
wibox_attach(L, -3, &globalconf.screens.tab[screen]);
|
wibox_attach(L, -3, &globalconf.screens.tab[screen]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1353,17 +1213,7 @@ luaA_wibox_set_border_color(lua_State *L, wibox_t *wibox)
|
||||||
static int
|
static int
|
||||||
luaA_wibox_set_visible(lua_State *L, wibox_t *wibox)
|
luaA_wibox_set_visible(lua_State *L, wibox_t *wibox)
|
||||||
{
|
{
|
||||||
bool b = luaA_checkboolean(L, -1);
|
wibox_set_visible(L, -3, luaA_checkboolean(L, -1));
|
||||||
if(b != wibox->visible)
|
|
||||||
switch(wibox->type)
|
|
||||||
{
|
|
||||||
case WIBOX_TYPE_NORMAL:
|
|
||||||
wibox_set_visible(L, -3, b);
|
|
||||||
break;
|
|
||||||
case WIBOX_TYPE_TITLEBAR:
|
|
||||||
titlebar_set_visible(wibox, b);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1537,18 +1387,6 @@ wibox_class_setup(lua_State *L)
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_cursor,
|
(lua_class_propfunc_t) luaA_wibox_set_cursor,
|
||||||
(lua_class_propfunc_t) luaA_wibox_get_cursor,
|
(lua_class_propfunc_t) luaA_wibox_get_cursor,
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_cursor);
|
(lua_class_propfunc_t) luaA_wibox_set_cursor);
|
||||||
luaA_class_add_property(&wibox_class, A_TK_CLIENT,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_client,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_get_client,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_client);
|
|
||||||
luaA_class_add_property(&wibox_class, A_TK_POSITION,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_position,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_get_position,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_position);
|
|
||||||
luaA_class_add_property(&wibox_class, A_TK_ALIGN,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_align,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_get_align,
|
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_align);
|
|
||||||
luaA_class_add_property(&wibox_class, A_TK_FG,
|
luaA_class_add_property(&wibox_class, A_TK_FG,
|
||||||
(lua_class_propfunc_t) luaA_wibox_set_fg,
|
(lua_class_propfunc_t) luaA_wibox_set_fg,
|
||||||
(lua_class_propfunc_t) luaA_wibox_get_fg,
|
(lua_class_propfunc_t) luaA_wibox_get_fg,
|
||||||
|
|
|
@ -26,13 +26,6 @@
|
||||||
#include "strut.h"
|
#include "strut.h"
|
||||||
#include "common/luaobject.h"
|
#include "common/luaobject.h"
|
||||||
|
|
||||||
/** Wibox types */
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
WIBOX_TYPE_NORMAL = 0,
|
|
||||||
WIBOX_TYPE_TITLEBAR
|
|
||||||
} wibox_type_t;
|
|
||||||
|
|
||||||
/** Wibox type */
|
/** Wibox type */
|
||||||
struct wibox_t
|
struct wibox_t
|
||||||
{
|
{
|
||||||
|
@ -41,12 +34,6 @@ struct wibox_t
|
||||||
bool ontop;
|
bool ontop;
|
||||||
/** Visible */
|
/** Visible */
|
||||||
bool visible;
|
bool visible;
|
||||||
/** Position */
|
|
||||||
position_t position;
|
|
||||||
/** Wibox type */
|
|
||||||
wibox_type_t type;
|
|
||||||
/** Alignment */
|
|
||||||
alignment_t align;
|
|
||||||
/** Screen */
|
/** Screen */
|
||||||
screen_t *screen;
|
screen_t *screen;
|
||||||
/** Widget list */
|
/** Widget list */
|
||||||
|
@ -62,8 +49,6 @@ struct wibox_t
|
||||||
char *cursor;
|
char *cursor;
|
||||||
/** Background image */
|
/** Background image */
|
||||||
image_t *bg_image;
|
image_t *bg_image;
|
||||||
/* Banned? used for titlebars */
|
|
||||||
bool isbanned;
|
|
||||||
/** Button bindings */
|
/** Button bindings */
|
||||||
button_array_t buttons;
|
button_array_t buttons;
|
||||||
/** The window object. */
|
/** The window object. */
|
||||||
|
@ -106,12 +91,9 @@ void luaA_wibox_invalidate_byitem(lua_State *, const void *);
|
||||||
|
|
||||||
wibox_t * wibox_getbywin(xcb_window_t);
|
wibox_t * wibox_getbywin(xcb_window_t);
|
||||||
|
|
||||||
void wibox_moveresize(lua_State *, int, area_t);
|
|
||||||
void wibox_refresh_pixmap_partial(wibox_t *, int16_t, int16_t, uint16_t, uint16_t);
|
|
||||||
void wibox_init(wibox_t *, int);
|
|
||||||
void wibox_wipe(wibox_t *);
|
|
||||||
void wibox_set_opacity(lua_State *, int, double);
|
void wibox_set_opacity(lua_State *, int, double);
|
||||||
void wibox_set_orientation(lua_State *, int, orientation_t);
|
|
||||||
|
void wibox_refresh_pixmap_partial(wibox_t *, int16_t, int16_t, uint16_t, uint16_t);
|
||||||
|
|
||||||
void wibox_class_setup(lua_State *);
|
void wibox_class_setup(lua_State *);
|
||||||
|
|
||||||
|
|
|
@ -370,7 +370,7 @@ widget_invalidate_bytype(widget_constructor_t *type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set a wibox needs update because it has widget, or redraw a titlebar.
|
/** Set a wibox needs update because it has widget.
|
||||||
* \param widget The widget to look for.
|
* \param widget The widget to look for.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
|
@ -384,18 +384,6 @@ widget_invalidate_bywidget(widget_t *widget)
|
||||||
(*wibox)->need_update = true;
|
(*wibox)->need_update = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(_c, globalconf.clients)
|
|
||||||
{
|
|
||||||
client_t *c = *_c;
|
|
||||||
if(c->titlebar && !c->titlebar->need_update)
|
|
||||||
for(int j = 0; j < c->titlebar->widgets.len; j++)
|
|
||||||
if(c->titlebar->widgets.tab[j].widget == widget)
|
|
||||||
{
|
|
||||||
c->titlebar->need_update = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create a new widget.
|
/** Create a new widget.
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
#include "objects/widget.h"
|
#include "objects/widget.h"
|
||||||
#include "luaa.h"
|
#include "luaa.h"
|
||||||
#include "titlebar.h"
|
|
||||||
|
|
||||||
/** The imagebox private data structure */
|
/** The imagebox private data structure */
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -62,18 +62,7 @@ static void
|
||||||
systray_draw(widget_t *widget, draw_context_t *ctx,
|
systray_draw(widget_t *widget, draw_context_t *ctx,
|
||||||
area_t geometry, wibox_t *p)
|
area_t geometry, wibox_t *p)
|
||||||
{
|
{
|
||||||
uint32_t orient;
|
uint32_t orient = _NET_SYSTEM_TRAY_ORIENTATION_HORZ;
|
||||||
|
|
||||||
switch(p->position)
|
|
||||||
{
|
|
||||||
case Right:
|
|
||||||
case Left:
|
|
||||||
orient = _NET_SYSTEM_TRAY_ORIENTATION_VERT;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
orient = _NET_SYSTEM_TRAY_ORIENTATION_HORZ;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
systray_data_t *d = widget->data;
|
systray_data_t *d = widget->data;
|
||||||
d->height = p->geometry.height;
|
d->height = p->geometry.height;
|
||||||
|
|
3
screen.c
3
screen.c
|
@ -270,9 +270,6 @@ screen_client_moveto(client_t *c, screen_t *new_screen, bool doresize)
|
||||||
|
|
||||||
c->screen = new_screen;
|
c->screen = new_screen;
|
||||||
|
|
||||||
if(c->titlebar)
|
|
||||||
c->titlebar->screen = new_screen;
|
|
||||||
|
|
||||||
/* If client was on a screen, remove old tags */
|
/* If client was on a screen, remove old tags */
|
||||||
if(old_screen)
|
if(old_screen)
|
||||||
foreach(old_tag, old_screen->tags)
|
foreach(old_tag, old_screen->tags)
|
||||||
|
|
366
titlebar.c
366
titlebar.c
|
@ -1,366 +0,0 @@
|
||||||
/*
|
|
||||||
* titlebar.c - titlebar management
|
|
||||||
*
|
|
||||||
* Copyright © 2008-2009 Julien Danjou <julien@danjou.info>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <xcb/xcb.h>
|
|
||||||
|
|
||||||
#include "titlebar.h"
|
|
||||||
#include "objects/client.h"
|
|
||||||
#include "objects/widget.h"
|
|
||||||
#include "objects/wibox.h"
|
|
||||||
#include "screen.h"
|
|
||||||
#include "luaa.h"
|
|
||||||
|
|
||||||
/** Get a client by its titlebar.
|
|
||||||
* \param titlebar The titlebar.
|
|
||||||
* \return A client.
|
|
||||||
*/
|
|
||||||
client_t *
|
|
||||||
client_getbytitlebar(wibox_t *titlebar)
|
|
||||||
{
|
|
||||||
foreach(c, globalconf.clients)
|
|
||||||
if((*c)->titlebar == titlebar)
|
|
||||||
return *c;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get a client by its titlebar window.
|
|
||||||
* \param win The window.
|
|
||||||
* \return A client.
|
|
||||||
*/
|
|
||||||
client_t *
|
|
||||||
client_getbytitlebarwin(xcb_window_t win)
|
|
||||||
{
|
|
||||||
foreach(c, globalconf.clients)
|
|
||||||
if((*c)->titlebar && (*c)->titlebar->window == win)
|
|
||||||
return *c;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Move a titlebar out of the viewport.
|
|
||||||
* \param titlebar The titlebar.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
titlebar_ban(wibox_t *titlebar)
|
|
||||||
{
|
|
||||||
/* Do it manually because client geometry remains unchanged. */
|
|
||||||
if(titlebar && !titlebar->isbanned)
|
|
||||||
{
|
|
||||||
client_t *c;
|
|
||||||
|
|
||||||
if(titlebar->window)
|
|
||||||
xcb_unmap_window(globalconf.connection, titlebar->window);
|
|
||||||
|
|
||||||
/* Remove titlebar geometry from client. */
|
|
||||||
if((c = client_getbytitlebar(titlebar)))
|
|
||||||
c->geometry = titlebar_geometry_remove(titlebar, 0, c->geometry);
|
|
||||||
|
|
||||||
titlebar->isbanned = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Move a titlebar on top of its client.
|
|
||||||
* \param titlebar The titlebar.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
titlebar_unban(wibox_t *titlebar)
|
|
||||||
{
|
|
||||||
/* Do this manually because the system doesn't know we moved the toolbar.
|
|
||||||
* Note that !visible titlebars are unmapped and for fullscreen it'll
|
|
||||||
* end up offscreen anyway. */
|
|
||||||
if(titlebar && titlebar->isbanned)
|
|
||||||
{
|
|
||||||
client_t *c;
|
|
||||||
|
|
||||||
if(titlebar->window)
|
|
||||||
xcb_map_window(globalconf.connection, titlebar->window);
|
|
||||||
|
|
||||||
titlebar->isbanned = false;
|
|
||||||
|
|
||||||
/* Add titlebar geometry from client. */
|
|
||||||
if((c = client_getbytitlebar(titlebar)))
|
|
||||||
c->geometry = titlebar_geometry_add(titlebar, 0, c->geometry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get titlebar area.
|
|
||||||
* \param c The client
|
|
||||||
* \param geometry The client geometry including borders, excluding titlebars.
|
|
||||||
* \param res Pointer to area of titlebar, must be allocated already.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res)
|
|
||||||
{
|
|
||||||
int height, width, x_offset = 0, y_offset = 0;
|
|
||||||
|
|
||||||
switch(c->titlebar->position)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
case Top:
|
|
||||||
width = MAX(1, geometry.width);
|
|
||||||
switch(c->titlebar->align)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
case AlignRight:
|
|
||||||
x_offset = geometry.width - width;
|
|
||||||
break;
|
|
||||||
case AlignCenter:
|
|
||||||
x_offset = (geometry.width - width) / 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
res->x = geometry.x + x_offset;
|
|
||||||
res->y = geometry.y - c->titlebar->geometry.height;
|
|
||||||
res->width = width;
|
|
||||||
res->height = c->titlebar->geometry.height;
|
|
||||||
break;
|
|
||||||
case Bottom:
|
|
||||||
width = MAX(1, geometry.width);
|
|
||||||
switch(c->titlebar->align)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
case AlignRight:
|
|
||||||
x_offset = geometry.width - width;
|
|
||||||
break;
|
|
||||||
case AlignCenter:
|
|
||||||
x_offset = (geometry.width - width) / 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
res->x = geometry.x + x_offset;
|
|
||||||
res->y = geometry.y + geometry.height;
|
|
||||||
res->width = width;
|
|
||||||
res->height = c->titlebar->geometry.height;
|
|
||||||
break;
|
|
||||||
case Left:
|
|
||||||
height = MAX(1, geometry.height);
|
|
||||||
switch(c->titlebar->align)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
case AlignRight:
|
|
||||||
y_offset = geometry.height - height;
|
|
||||||
break;
|
|
||||||
case AlignCenter:
|
|
||||||
y_offset = (geometry.height - height) / 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
res->x = geometry.x - c->titlebar->geometry.width;
|
|
||||||
res->y = geometry.y + y_offset;
|
|
||||||
res->width = c->titlebar->geometry.width;
|
|
||||||
res->height = height;
|
|
||||||
break;
|
|
||||||
case Right:
|
|
||||||
height = MAX(1, geometry.height);
|
|
||||||
switch(c->titlebar->align)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
case AlignRight:
|
|
||||||
y_offset = geometry.height - height;
|
|
||||||
break;
|
|
||||||
case AlignCenter:
|
|
||||||
y_offset = (geometry.height - height) / 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
res->x = geometry.x + geometry.width;
|
|
||||||
res->y = geometry.y + y_offset;
|
|
||||||
res->width = c->titlebar->geometry.width;
|
|
||||||
res->height = height;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Detach a wibox titlebar from its client.
|
|
||||||
* \param c The client.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
titlebar_client_detach(client_t *c)
|
|
||||||
{
|
|
||||||
/* If client has a titlebar, kick it out. */
|
|
||||||
if(c && c->titlebar)
|
|
||||||
{
|
|
||||||
/* Update client geometry to exclude the titlebar. */
|
|
||||||
c->geometry = titlebar_geometry_remove(c->titlebar, 0, c->geometry);
|
|
||||||
wibox_wipe(c->titlebar);
|
|
||||||
c->titlebar->type = WIBOX_TYPE_NORMAL;
|
|
||||||
c->titlebar->screen = NULL;
|
|
||||||
|
|
||||||
luaA_object_unref(globalconf.L, c->titlebar);
|
|
||||||
c->titlebar = NULL;
|
|
||||||
|
|
||||||
luaA_object_push(globalconf.L, c);
|
|
||||||
luaA_object_emit_signal(globalconf.L, -1, "property::titlebar", 0);
|
|
||||||
lua_pop(globalconf.L, 1);
|
|
||||||
client_stack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Attach a wibox to a client as its titlebar.
|
|
||||||
* \param c The client.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
titlebar_client_attach(client_t *c)
|
|
||||||
{
|
|
||||||
/* check if we can register the object */
|
|
||||||
wibox_t *t = luaA_object_ref_class(globalconf.L, -1, &wibox_class);
|
|
||||||
|
|
||||||
titlebar_client_detach(c);
|
|
||||||
|
|
||||||
/* check if titlebar is already on a client */
|
|
||||||
titlebar_client_detach(client_getbytitlebar(t));
|
|
||||||
|
|
||||||
/* check if client already has a titlebar. */
|
|
||||||
titlebar_client_detach(c);
|
|
||||||
|
|
||||||
/* set the object as new client's titlebar */
|
|
||||||
c->titlebar = t;
|
|
||||||
|
|
||||||
t->type = WIBOX_TYPE_TITLEBAR;
|
|
||||||
t->screen = c->screen;
|
|
||||||
|
|
||||||
switch(t->position)
|
|
||||||
{
|
|
||||||
case Top:
|
|
||||||
case Bottom:
|
|
||||||
if(!t->geometry.height)
|
|
||||||
t->geometry.height = 1.5 * globalconf.font->height;
|
|
||||||
break;
|
|
||||||
case Left:
|
|
||||||
case Right:
|
|
||||||
if(!t->geometry.width)
|
|
||||||
t->geometry.width = 1.5 * globalconf.font->height;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Update client geometry to include the titlebar. */
|
|
||||||
c->geometry = titlebar_geometry_add(c->titlebar, 0, c->geometry);
|
|
||||||
|
|
||||||
/* Client geometry without titlebar, but including borders, since that is always consistent. */
|
|
||||||
titlebar_geometry_compute(c, titlebar_geometry_remove(c->titlebar, 0, c->geometry), &t->geometry);
|
|
||||||
|
|
||||||
wibox_init(t, c->phys_screen);
|
|
||||||
|
|
||||||
t->need_update = true;
|
|
||||||
|
|
||||||
/* Call update geometry. This will move the wibox to the right place,
|
|
||||||
* which might be the same as `wingeom', but then it will ban the
|
|
||||||
* titlebar if needed. */
|
|
||||||
titlebar_update_geometry(c);
|
|
||||||
|
|
||||||
xcb_map_window(globalconf.connection, t->window);
|
|
||||||
|
|
||||||
luaA_object_push(globalconf.L, c);
|
|
||||||
luaA_object_emit_signal(globalconf.L, -1, "property::titlebar", 0);
|
|
||||||
lua_pop(globalconf.L, 1);
|
|
||||||
client_stack();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Map or unmap a titlebar wibox.
|
|
||||||
* \param t The wibox/titlebar.
|
|
||||||
* \param visible The new state of the titlebar.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
titlebar_set_visible(wibox_t *t, bool visible)
|
|
||||||
{
|
|
||||||
if(visible != t->visible)
|
|
||||||
{
|
|
||||||
if((t->visible = visible))
|
|
||||||
titlebar_unban(t);
|
|
||||||
else
|
|
||||||
titlebar_ban(t);
|
|
||||||
|
|
||||||
client_stack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
luaA_titlebar_set_position(lua_State *L, int udx)
|
|
||||||
{
|
|
||||||
wibox_t *titlebar = luaA_checkudata(L, udx, &wibox_class);
|
|
||||||
size_t len;
|
|
||||||
const char *buf = luaL_checklstring(L, -1, &len);
|
|
||||||
position_t position = position_fromstr(buf, len);
|
|
||||||
if(position != titlebar->position)
|
|
||||||
{
|
|
||||||
switch(position)
|
|
||||||
{
|
|
||||||
case Left:
|
|
||||||
switch(titlebar->position)
|
|
||||||
{
|
|
||||||
int tmp;
|
|
||||||
case Left:
|
|
||||||
case Right:
|
|
||||||
break;
|
|
||||||
case Top:
|
|
||||||
case Bottom:
|
|
||||||
tmp = titlebar->geometry.width;
|
|
||||||
titlebar->geometry.width = titlebar->geometry.height;
|
|
||||||
titlebar->geometry.height = tmp;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
wibox_set_orientation(L, udx, North);
|
|
||||||
break;
|
|
||||||
case Right:
|
|
||||||
switch(titlebar->position)
|
|
||||||
{
|
|
||||||
int tmp;
|
|
||||||
case Left:
|
|
||||||
case Right:
|
|
||||||
break;
|
|
||||||
case Top:
|
|
||||||
case Bottom:
|
|
||||||
tmp = titlebar->geometry.width;
|
|
||||||
titlebar->geometry.width = titlebar->geometry.height;
|
|
||||||
titlebar->geometry.height = tmp;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
wibox_set_orientation(L, udx, South);
|
|
||||||
break;
|
|
||||||
case Top:
|
|
||||||
case Bottom:
|
|
||||||
switch(titlebar->position)
|
|
||||||
{
|
|
||||||
int tmp;
|
|
||||||
case Left:
|
|
||||||
case Right:
|
|
||||||
tmp = titlebar->geometry.width;
|
|
||||||
titlebar->geometry.width = titlebar->geometry.height;
|
|
||||||
titlebar->geometry.height = tmp;
|
|
||||||
break;
|
|
||||||
case Top:
|
|
||||||
case Bottom:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
wibox_set_orientation(L, udx, East);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
titlebar->position = position;
|
|
||||||
client_t *c;
|
|
||||||
if((c = client_getbytitlebar(titlebar)))
|
|
||||||
titlebar_update_geometry(c);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
|
156
titlebar.h
156
titlebar.h
|
@ -1,156 +0,0 @@
|
||||||
/*
|
|
||||||
* titlebar.h - titlebar management header
|
|
||||||
*
|
|
||||||
* Copyright © 2008-2009 Julien Danjou <julien@danjou.info>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef AWESOME_TITLEBAR_H
|
|
||||||
#define AWESOME_TITLEBAR_H
|
|
||||||
|
|
||||||
#include "objects/wibox.h"
|
|
||||||
#include "objects/client.h"
|
|
||||||
#include "window.h"
|
|
||||||
|
|
||||||
client_t * client_getbytitlebar(wibox_t *);
|
|
||||||
client_t * client_getbytitlebarwin(xcb_window_t);
|
|
||||||
void titlebar_geometry_compute(client_t *, area_t, area_t *);
|
|
||||||
void titlebar_init(client_t *);
|
|
||||||
void titlebar_client_detach(client_t *);
|
|
||||||
void titlebar_client_attach(client_t *);
|
|
||||||
void titlebar_set_visible(wibox_t *, bool);
|
|
||||||
void titlebar_ban(wibox_t *);
|
|
||||||
void titlebar_unban(wibox_t *);
|
|
||||||
|
|
||||||
int luaA_titlebar_set_position(lua_State *, int);
|
|
||||||
|
|
||||||
static inline bool
|
|
||||||
titlebar_isvisible(client_t *c, screen_t *screen)
|
|
||||||
{
|
|
||||||
if(client_isvisible(c, screen))
|
|
||||||
{
|
|
||||||
if(c->fullscreen)
|
|
||||||
return false;
|
|
||||||
if(!c->titlebar || !c->titlebar->visible)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Add the titlebar geometry and border to a geometry.
|
|
||||||
* \param t The titlebar
|
|
||||||
* \param border The client border size.
|
|
||||||
* \param geometry The geometry
|
|
||||||
* \return A new geometry bigger if the titlebar is visible.
|
|
||||||
*/
|
|
||||||
static inline area_t
|
|
||||||
titlebar_geometry_add(wibox_t *t, int border, area_t geometry)
|
|
||||||
{
|
|
||||||
/* We need to add titlebar border to the total width and height.
|
|
||||||
* This can then be subtracted/added to the width/height/x/y.
|
|
||||||
* In this case the border is included, because it belongs to a different window.
|
|
||||||
*/
|
|
||||||
if(t && t->visible)
|
|
||||||
switch(t->position)
|
|
||||||
{
|
|
||||||
case Top:
|
|
||||||
geometry.y -= t->geometry.height;
|
|
||||||
geometry.height += t->geometry.height;
|
|
||||||
break;
|
|
||||||
case Bottom:
|
|
||||||
geometry.height += t->geometry.height;
|
|
||||||
break;
|
|
||||||
case Left:
|
|
||||||
geometry.x -= t->geometry.width;
|
|
||||||
geometry.width += t->geometry.width;
|
|
||||||
break;
|
|
||||||
case Right:
|
|
||||||
geometry.width += t->geometry.width;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Adding a border to a client only changes width and height, x and y are including border. */
|
|
||||||
geometry.width += 2 * border;
|
|
||||||
geometry.height += 2 * border;
|
|
||||||
|
|
||||||
return geometry;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Remove the titlebar geometry and border width to a geometry.
|
|
||||||
* \param t The titlebar.
|
|
||||||
* \param border The client border size.
|
|
||||||
* \param geometry The geometry.
|
|
||||||
* \return A new geometry smaller if the titlebar is visible.
|
|
||||||
*/
|
|
||||||
static inline area_t
|
|
||||||
titlebar_geometry_remove(wibox_t *t, int border, area_t geometry)
|
|
||||||
{
|
|
||||||
/* We need to add titlebar border to the total width and height.
|
|
||||||
* This can then be subtracted/added to the width/height/x/y.
|
|
||||||
* In this case the border is included, because it belongs to a different window.
|
|
||||||
*/
|
|
||||||
if(t && t->visible)
|
|
||||||
switch(t->position)
|
|
||||||
{
|
|
||||||
case Top:
|
|
||||||
geometry.y += t->geometry.height;
|
|
||||||
unsigned_subtract(geometry.height, t->geometry.height);
|
|
||||||
break;
|
|
||||||
case Bottom:
|
|
||||||
unsigned_subtract(geometry.height, t->geometry.height);
|
|
||||||
break;
|
|
||||||
case Left:
|
|
||||||
geometry.x += t->geometry.width;
|
|
||||||
unsigned_subtract(geometry.width, t->geometry.width);
|
|
||||||
break;
|
|
||||||
case Right:
|
|
||||||
unsigned_subtract(geometry.width, t->geometry.width);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Adding a border to a client only changes width and height, x and y are including border. */
|
|
||||||
unsigned_subtract(geometry.width, 2*border);
|
|
||||||
unsigned_subtract(geometry.height, 2*border);
|
|
||||||
|
|
||||||
return geometry;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Update the titlebar geometry for a client.
|
|
||||||
* \param c The client.
|
|
||||||
*/
|
|
||||||
static inline void
|
|
||||||
titlebar_update_geometry(client_t *c)
|
|
||||||
{
|
|
||||||
area_t geom;
|
|
||||||
|
|
||||||
if(!c->titlebar)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Client geometry without titlebar, but including borders, since that is always consistent. */
|
|
||||||
titlebar_geometry_compute(c, titlebar_geometry_remove(c->titlebar, 0, c->geometry), &geom);
|
|
||||||
luaA_object_push(globalconf.L, c->titlebar);
|
|
||||||
wibox_moveresize(globalconf.L, -1, geom);
|
|
||||||
lua_pop(globalconf.L, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
|
Loading…
Reference in New Issue