Skip to content

Extending the wayfire-shell-unstable-v2 protocol#3019

Open
marcusbritanicus wants to merge 4 commits into
WayfireWM:masterfrom
marcus-wayfire:master
Open

Extending the wayfire-shell-unstable-v2 protocol#3019
marcusbritanicus wants to merge 4 commits into
WayfireWM:masterfrom
marcus-wayfire:master

Conversation

@marcusbritanicus

@marcusbritanicus marcusbritanicus commented Apr 30, 2026

Copy link
Copy Markdown
Contributor
  • Added create_positioned_hotspot request to zwf_output_v2 interface.
  • Added create_custom_hotspot request to zwf_output_v2 interface.
  • Added proximity_changed event to zwf_hotspot_v2 interface.
  • All hotspots (edge, corner, positioned) will now get proximity_changed signals

- Added create_positioned_hotspot request to zwf_output_v2 interface.
- Added proximity_changed event to zwf_hotspot_v2 interface.
- All hotspots (edge, corner, positioned) will now get proximity_changed
  signals
- Replaced create_positioned_hotspot(...) with
  create_custom_hotspot(...)

@ammen99 ammen99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm overall, a few things I noticed, I trust you have tested this :)

Comment thread proto/wayfire-shell-unstable-v2.xml Outdated
whenever the input pointer moves within the hotspot area.

Proximity indicates the current distance in pixels from the input pointer
to the trigger point of the hotspot:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this wording a bit confusing, is there a 'trigger point of the hotspot'? I thought hotspots can be rectangles.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, hotspots can be rectangles. I tried to write a general explanation, which was way too confusing. In case of the rectangle, there are simply 2(l+b) trigger points along the perimeter of the rectangle. So, in the rectangular case, the point on the perimeter closest to the mouse is the "trigger point".

I agree that it can be a bit misleading. If you have a better wording, I am happy to incorporate it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proximity is defined as the length of the shortest segment connecting the input pointer to the boundary of the hotspot rectangle or something like it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I have come up with:

Proximity is defined as the Euclidean distance in pixels from the input pointer to the hotspot's trigger geometry, clamped to the threshold:

Comment thread plugins/protocols/wayfire-shell.cpp Outdated
wf::geometry_t calculate_trigger_geometry(uint32_t edge_mask)
{
wf::geometry_t output_geom = this->output->get_layout_geometry();
int edge_count = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks quite inefficient, can't we replace it by __builtin_popcount? We already use these types of functions in other places.

Comment thread plugins/protocols/wayfire-shell.cpp Outdated

void send_proximity_if_needed(const wf::point_t& cursor)
{
if (wl_resource_get_version(hotspot_resource) < 2)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be a macro defined as the version in which proximity was defined (in the protocol header created by wayland-scanner).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what you mean is

if (wl_resource_get_version(hotspot_resource) < ZWF_SHELL_HOTSPOT_V2_PROXIMITY_SINCE_VERSION)

Please correct me if I am wrong.


uint32_t calculate_proximity(const wf::point_t& cursor) const
{
const auto& rect = trigger;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ammen99 Sure, I could use that. But to what end? I still have to calculate the distance to the box. Which means, I either have to do all the calculations. And I have to handle the edge cases separately: I allow the box to be empty, wlr dose not.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcusbritanicus Sure but to me a code which looks like this:

auto point = closest_point(box, target)
return dist(point, target)

looks way simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants