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
feat: Change cursors over clickable/scrollable areas #727
Conversation
I'll take a look at this tomorrow |
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.
This looks great. There are some minor things, I think should be addressed.
This works on my system, I'm currently setting up a testing VM with multiple WMs, I'll test it over there too once I'm done.
|
||
POLYBAR_NS | ||
|
||
namespace cursor_util { |
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.
Do I understand this right that there are three types of cursors pointer
, ns-resize
and default
and these vectors are just a list of fallback names if the xcb doesn't recognize a certain cursor name?
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.
Yes, I have chosen three relevant cursors to be used (we could add more but IMO those are the ones which are most likely to be used). Their names are not standardized so we have to cycle through them until we find one that exists in the current theme.
include/x11/cursor.hpp
Outdated
|
||
namespace cursor_util { | ||
static const vector<string> pointer_names {"pointing_hand", "pointer", "hand", "hand1", "hand2", "e29285e634086352946a0e7090d73106", "9d800788f1b08800ae810202380a0822"}; | ||
static const vector<string> arrow_names {"left_ptr", "arrow", "dnd-none", "op_left_arrow"}; |
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.
For clarity we should probably name this default_names
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.
Fair enough.
@@ -126,6 +130,8 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const | |||
m_opts.dimvalue = m_conf.get(bs, "dim-value", 1.0); | |||
m_opts.dimvalue = math_util::cap(m_opts.dimvalue, 0.0, 1.0); | |||
|
|||
m_opts.cursor_click = m_conf.get(bs, "cursor-click", ""s); | |||
m_opts.cursor_scroll = m_conf.get(bs, "cursor-scroll", ""s); |
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.
I think having pointer
and ns-resize
as default values would be a good idea
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.
Also it would be useful to the user if polybar showed a warning, if the config uses an invalid cursor name.
We could maybe have a map that maps cursor names to name vectors. Like this we have all valid cursor names as well as their xcb names in one spot and set_cursor
in cursor.cpp
could just access the map instead of using a long if-elseif chain. This would also make it easier to, in the future, add new cursor names.
Do you think |
I've made it optional for now because currently we don't have write access to the packages. Once we are able to change them, I'll probably make it a normal dependency. |
I think this PR should then add |
34b3a17
to
9b9e8c5
Compare
src/components/bar.cpp
Outdated
bool found_scroll = false; | ||
const auto find_click_area = [&](const action& action) { | ||
if (!m_opts.cursor_click.empty() && | ||
(action.button == mousebtn::LEFT || action.button == mousebtn::MIDDLE || action.button == mousebtn::RIGHT)) { |
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.
Double clicks probably should also show the click cursor
9b9e8c5
to
f91df60
Compare
f91df60
to
70023b0
Compare
Should be fixed now, please check. |
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.
Can you also add the two new options to the sample configuration with the values pointer
and ns-resize
.
I think after that we can merge this
Breaking Changes: * Date module no longer supports non-padded specifiers (i.e. `%-d`) and potentially other specifiers, see #792 - Check http://en.cppreference.com/w/cpp/io/manip/put_time to see supported specifiers * Setting background color to `background-0` with gradients (refer to https://github.com/jaagr/polybar/wiki/Known-Issues) Changelog: Features: * Feat(mpd): State-specific formats (`format-playing`, `format-paused`, `format-stopped`) (#567), see #524 * Feat(ipc): Visibility commands (show, hide, toggle, restart, quit) (b6c5563) * Feat(shell): Bash completion (#588) * Feat(menu): `expand-right` option (#658), see #655 * Feat(temperature): hwmon sysfs support (#688), see #404 * Feat(cursor): Change cursors over clickable/scrollable areas (#727), see #721 * Feat(temperature): Fahrenheit and Celsius tokens (#804) * Feat(mpd): Use mpd name tag or URI as fallback for title-less tracks (#823), see #815 Fixes: * Fix(i3): Clicking workspaces without index (#521), see #520 * Fix(parser): Prefix options overriding format options (#729), see #544 * Fix(parser): Overline tags (eebf105) * Fix(process_util): Prefix shell environment variable (`$POLYBAR_SHELL`) (86ff947), see #566 * Fix(parser): `%{R}` tag (reverse colors) (0bd8f1f), see #585 * Fix(renderer): Center block position with tray (389bae2 & #673), see #551 & #672 * Fix(xworkpaces): Active workspace with XMonad (#587), see #411 & #535 * Fix(config): Expand tilde, environment variable (d3b0670 & #724), see #603 & #719 * Fix(build): Remove curlbuild.h (#648), see #647 * Fix(renderer): Off by one error for actions (#663), see #661 * Fix(gcc): GCC 7.1 ([jaagr/xpp/#6](polybar/xpp#6)) * Fix(fs): Use `bytes_available` for `percentage_used` (138f5fa), see #710 * Fix(fs): Use `f_frsize` for calculations (a682d2a) * Fix(date): Remove date string length limitation (#745), see #754 * Fix(renderer): Nested actions (#772), see #760 and #758 * Fix(i3): Check and warn if current workspace not found (#826), see #824 * Fix(github): Prevent module disappearing with no connection (#811), see #810 * Fix(renderer): Module gradients (#831), see #759 * Fix(build): Update deprecated jsoncpp Reader
Implements changing cursors when a clickable/scrollable area is hovered over. This can be configured in the bar settings using
cursor-click
andcursor-scroll
, where the supported cursors (other than the default) arepointer
andns-resize
(using the CSS values).I currently have the
xcb-cursor
dependency as optional because the polybar-git AUR package would need to be updated.I might implement disabling this feature per-module in the future as requested in #721, but maybe in a later PR as it will be fairly complicated.
Closes #721.