-
Notifications
You must be signed in to change notification settings - Fork 599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename awful.popup
hide_on_right_click
property to hide_on_click
#3665
base: master
Are you sure you want to change the base?
Changes from all commits
d3e11a4
d536a50
cd8df4f
40ec479
2a16946
8ad78c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
-- @supermodule wibox | ||
--------------------------------------------------------------------------- | ||
local wibox = require( "wibox" ) | ||
local gdebug = require( "gears.debug" ) | ||
local gtable = require( "gears.table" ) | ||
local placement = require( "awful.placement" ) | ||
local xresources= require("beautiful.xresources") | ||
|
@@ -297,17 +298,28 @@ function popup:unbind_to_widget(widget) | |
widget:disconnect_signal("button::press", self._private.show_fct) | ||
end | ||
|
||
--- Hide the popup when right clicked. | ||
--- Hide the popup when clicked inside. | ||
-- | ||
-- @property hide_on_right_click | ||
-- @tparam[opt=false] boolean hide_on_right_click | ||
-- @property hide_on_click | ||
-- @tparam[opt=false] boolean hide_on_click | ||
-- @propemits true false | ||
|
||
function popup:set_hide_on_right_click(value) | ||
function popup:set_hide_on_click(value) | ||
self[value and "connect_signal" or "disconnect_signal"]( | ||
self, "button::press", self._private.hide_fct | ||
self, | ||
"button::press", | ||
self._private.hide_fct | ||
) | ||
self:emit_signal("property::hide_on_click", value) | ||
end | ||
function popup:set_hide_on_right_click(value) | ||
gdebug.deprecate( | ||
"Use popup:set_hide_on_click() instead of set_hide_on_right_click", | ||
{ deprecated_in = 4 } | ||
) | ||
self:emit_signal("property::hide_on_right_click", value) | ||
self:set_hide_on_click(value) | ||
end | ||
function popup:get_hide_on_click() | ||
return self:is_signal_connected("button::press", self._private.hide_fct) | ||
end | ||
|
||
--- The popup minimum width. | ||
|
@@ -453,8 +465,8 @@ end | |
-- @tparam string|table args.preferred_positions | ||
-- @tparam string|table args.preferred_anchors | ||
-- @tparam table|number args.offset The X and Y offset compared to the parent object | ||
-- @tparam boolean args.hide_on_right_click Whether or not to hide the popup on | ||
-- right clicks. | ||
-- @tparam boolean args.hide_on_click Whether or not to hide the popup on | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about turning it from boolean into int, so user could choose the mouse button? |
||
-- clicks. | ||
-- @constructorfct awful.popup | ||
local function create_popup(_, args) | ||
assert(args) | ||
|
@@ -509,12 +521,20 @@ local function create_popup(_, args) | |
-- when set_position is called before the limits | ||
for _,v in ipairs{"minimum_width", "minimum_height", "maximum_height", | ||
"maximum_width", "offset", "placement","preferred_positions", | ||
"preferred_anchors", "hide_on_right_click"} do | ||
"preferred_anchors", "hide_on_right_click", "hide_on_click"} do | ||
if args[v] ~= nil then | ||
w["set_"..v](w, args[v]) | ||
end | ||
end | ||
|
||
-- TODO : remove when we are ready to break backward compatibility | ||
if args.hide_on_right_click ~= nil then | ||
gdebug.deprecate( | ||
"Use the hide_on_click parameter instead of hide_on_right_click", | ||
{ deprecated_in = 4 } | ||
) | ||
end | ||
|
||
-- Default to visible | ||
if args.visible ~= false then | ||
w.visible = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,23 @@ function object:connect_signal(name, func) | |
sig.strong[func] = true | ||
end | ||
|
||
--- Check if the callback is connected to the signal. | ||
-- | ||
-- This function check both kind of signal connection (strong and weak). | ||
-- | ||
-- @tparam string name The name of the signal. | ||
-- @tparam function func The callback to check if connected. | ||
-- @treturn boolean Whether the signal is connected. | ||
-- @method is_signal_connected | ||
function object:is_signal_connected(name, func) | ||
assert( | ||
type(func) == "function", | ||
"callback must be a function, got: " .. type(func) | ||
) | ||
local sig = find_signal(self, name) | ||
return not not (sig and (sig.strong[func] or sig.weak[func])) | ||
Comment on lines
+76
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
end | ||
|
||
-- Register a global signal receiver. | ||
function object:_connect_everything(callback) | ||
table.insert(self._global_receivers, callback) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
local runner = require "_runner" | ||
local base = require "wibox.widget.base" | ||
local popup = require "awful.popup" | ||
|
||
local widget = base.make_widget() | ||
local p = popup { widget = widget } | ||
|
||
local function click(x, y) | ||
return function() | ||
mouse.coords { x = x, y = y } | ||
assert(mouse.coords().x == x and mouse.coords().y == y) | ||
root.fake_input("button_press", 1) | ||
awesome.sync() | ||
root.fake_input("button_release", 1) | ||
awesome.sync() | ||
return true | ||
end | ||
end | ||
|
||
runner.run_steps { | ||
function() | ||
assert(p.visible) | ||
assert(not p.hide_on_click) | ||
return true | ||
end, | ||
click(p.x, p.y), | ||
function() | ||
assert(p.visible) | ||
p.hide_on_click = true | ||
return true | ||
end, | ||
click(p.x, p.y), | ||
function() | ||
assert(not p.visible) | ||
assert(p.hide_on_click) | ||
return true | ||
end, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.