awesome icon indicating copy to clipboard operation
awesome copied to clipboard

Mouse signals on other wiboxes

Open kosorin opened this issue 2 years ago • 4 comments

I have custom context menu widgets. I'd like to implement this common feature:

  1. press and hold mouse button
  2. move the cursor to the item in the menu
  3. release the mouse button
  4. menu item action is executed

Sometimes it's faster and you save 1 more click.

Output of awesome --version:

awesome v4.3-1588-gb54e50ad6 (Too long) • Compiled against Lua 5.4.4 (running with 0.9.2) • API level: 4 • D-Bus support: yes • xcb-errors support: no • execinfo support: yes • xcb-randr version: 1.6 • LGI version: /usr/share/lua/5.4/lgi/version.lua • Transparency enabled: yes • Custom search paths: no

How to reproduce the issue:

  1. press and hold any mouse button on wibox A
  2. move the cursor to any widget on wibox B

Actual result:

No signal is emitted (mouse::enter, mouse::leave, ...) for widgets on wibox B. Also no mouse buttons on wibox B works until the button is released.

Expected result:

All signals are emitted and all buttons on wibox B work regardless of the button press state.

kosorin avatar Feb 12 '23 23:02 kosorin

Do you use a mousegrabber? Or how did you try to implement this, its hard to know whats wrong without the code.

Crylia avatar Mar 06 '23 11:03 Crylia

Just regular mouse::*/button::* signals.

Here is rc.lua where you can try it:

  1. press and hold mouse button on "foo"
  2. move cursor over "bar" (the same wibox) => output "+ enter bar" and " leave bar"
  3. move cursor over "qux" (different wibox) => no output
  4. release mouse button
  5. move cursor over "qux" (different wibox) => output "+ enter qux" and " leave qux"
local awful = require("awful")
local wibox = require("wibox")

local function create_widget(text)
    local w = wibox.widget {
        widget = wibox.container.background,
        bg = "#cccccc",
        border_color = "#eeeeee",
        border_width = 1,
        {
            widget = wibox.container.margin,
            margins = 20,
            {
                widget = wibox.widget.textbox,
                text = text,
            },
        },
    }
    w:connect_signal("mouse::enter", function() print("+ enter", text) end)
    w:connect_signal("mouse::leave", function() print("  leave", text) end)
    return w
end

awful.popup {
    bg = "#003300",
    fg = "#008800",
    x = 20,
    y = 20,
    widget = {
        widget = wibox.container.margin,
        margins = 20,
        {
            layout = wibox.layout.fixed.horizontal,
            spacing = 50,
            create_widget("foo"),
            create_widget("bar"),
        }
    },
}

awful.popup {
    bg = "#330000",
    fg = "#ff0000",
    x = 240,
    y = 20,
    widget = {
        widget = wibox.container.margin,
        margins = 20,
        {
            layout = wibox.layout.fixed.horizontal,
            spacing = 50,
            create_widget("qux")
        }
    },
}


kosorin avatar Mar 07 '23 16:03 kosorin

Every wibox is its own X11 client (what most people would call "window"). And as far as I know, no major windowing system supports the scenario where you start holding a mouse button on one window and then receiver events on a different window.

The X client that holds the context menu would likely need to be set up in a certain way (transient, maybe also certain event masks) for it to still receive events in that situation. And that would likely require specific support for this in the C core of drawin.

sclu1034 avatar May 22 '23 12:05 sclu1034

i think you need to use function wiboxes_under_mouse_pointer() for your situation

actionless avatar May 22 '23 19:05 actionless