-
Notifications
You must be signed in to change notification settings - Fork 216
place: add "pointer" mode #2912
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
Conversation
30b9fc5 to
4084121
Compare
plugins/single_plugins/place.cpp
Outdated
| { | ||
| wf::geometry_t window = view->get_pending_geometry(); | ||
| wf::point_t pos = wf::get_core().get_cursor_position().round_down(); | ||
| window.x = workarea.x + wf::clamp(pos.x - window.width / 2, |
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.
Prefer std::clamp, we had wf::clamp before moving to a newer C++ version, so it is there just for legacy code.
plugins/single_plugins/place.cpp
Outdated
| void pointer(wayfire_toplevel_view & view, wf::geometry_t workarea) | ||
| { | ||
| wf::geometry_t window = view->get_pending_geometry(); | ||
| wf::point_t pos = wf::get_core().get_cursor_position().round_down(); |
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.
One thing to keep in mind is multiple outputs. get_core().get_cursor_position() returns the cursor position in the output-layout coordinate system. Views, however, are positioned in output-local coordinate system (i.e relative to their current output). You could look at whether the view is bound to any output (view->get_output(), should be non-null for most views), then use
wayfire/src/api/wayfire/output.hpp
Lines 111 to 114 in 1188a56
| /** | |
| * Gets the cursor position relative to the output | |
| */ | |
| wf::pointf_t get_cursor_position() const; |
Position new windows centered under the mouse pointer, while keeping them fully within the workarea.
4084121 to
14e2342
Compare
ammen99
left a comment
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.
LGTM, thanks!
This adds a new mode to the "place" plug-in to position new windows centered under the mouse pointer, while keeping them fully within the workarea.
The advantage is that the user can control where the new window would be placed by pointing the mouse before starting an app (might be useless when starting apps from a panel, but works well when using wofi or starting apps via key binding, e.g. terminal). And the user can immediately interact with the new window or move it out of the way with minimal mouse effort.
No idea what this would do in a mouseless, touch-screen scenario.