From 3cf17a9faed45e541ca5a34b1b05a1f72edb9d31 Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Wed, 5 Nov 2008 16:22:13 +0100 Subject: [PATCH] titlebar: generate mouse_enter and button events for the entire titlebar (and redirect them to the client) Signed-off-by: Maarten Maathuis Signed-off-by: Julien Danjou --- lib/awful/titlebar.lua.in | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/awful/titlebar.lua.in b/lib/awful/titlebar.lua.in index 860e0b68e..113a4f2ed 100644 --- a/lib/awful/titlebar.lua.in +++ b/lib/awful/titlebar.lua.in @@ -50,16 +50,24 @@ function add(c, args) local title = capi.widget({ type = "textbox", name = "title", align = "flex" }) title.text = " " .. util.escape(c.name) .. " " + + -- Redirect relevant events to the client the titlebar belongs to local bts = { - capi.button({ }, 1, function (t) t.client:mouse_move() end), + capi.button({ }, 1, function (t) capi.client.focus = t.client t.client:raise() t.client:mouse_move() end), + capi.button({ args.modkey }, 1, function (t) t.client:mouse_move() end), capi.button({ args.modkey }, 3, function (t) t.client:mouse_resize() end) } title:buttons(bts) + function title.mouse_enter(s) hooks.user.call('mouse_enter', c) end local appicon = capi.widget({ type = "imagebox", name = "appicon", align = "left" }) appicon.image = c.icon + -- Also redirect events for appicon (So the entire titlebar behaves consistently) + appicon:buttons(bts) + function appicon.mouse_enter(s) hooks.user.call('mouse_enter', c) end + if theme.titlebar_close_button == "true" then local closef = widget.button({ name = "closef", align = "right", image = theme.titlebar_close_button_focus @@ -70,15 +78,18 @@ function add(c, args) or theme.titlebar_close_button_img_normal or "@AWESOME_ICON_PATH@/titlebar/close.png" }) - -- Bind kill button - local b = capi.button({ }, 1, nil, function (t) t.client:kill() end) - local bts = closef:buttons() - bts[#bts + 1] = b - closef:buttons(bts) - - bts = close:buttons() - bts[#bts + 1] = b + -- Bind kill button, also allow moving and resizing on this widget + local bts = + { + capi.button({ }, 1, nil, function (t) t.client:kill() end), + capi.button({ args.modkey }, 1, function (t) t.client:mouse_move() end), + capi.button({ args.modkey }, 3, function (t) t.client:mouse_resize() end) + } close:buttons(bts) + closef:buttons(bts) + -- Needed for sloppy focus beheaviour + function close.mouse_enter(s) hooks.user.call('mouse_enter', c) end + function closef.mouse_enter(s) hooks.user.call('mouse_enter', c) end tb.widgets = { appicon, title, closef, close } else