Skip to content
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

added option to choose the default monitor that the cursor will appea… #5847

Merged
merged 3 commits into from May 3, 2024

Conversation

ikalco
Copy link
Contributor

@ikalco ikalco commented May 2, 2024

Default monitor for cursor #5803

Describe your PR, what does it fix/add?

Adds an option (string) under general:default_cursor_monitor.
Then, whenever a new monitor is added, it checks whether it's name matches the above string.
If it does, then it will set the cursor to the middle of that monitor.

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

If the option isn't set then it functions the same as before

Also, technically if a new monitor is added after startup and it matches the name, then the cursor will be set to there.
To fix this you would need to make the code stop checking after startup or after all the initial monitors have been added.
I don't know how you would do that though

Is it ready for merging, or does it need work?

Probably, I tested it on my PC and changing the option does change which monitor the mouse appears in on startup

Copy link
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

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

To make this one-time:

  • add a static bool once = true inside the if and set it to false once you match one output
  • add a static std::chrono::system_clock::time_point firstTimeOrSomethign = std::chrono::system_clock::now(); with the same idea and give an arbitrary max time threshold (10s should be reasonable) after which the thing disables itself

src/events/Monitors.cpp Outdated Show resolved Hide resolved
@thejch
Copy link
Contributor

thejch commented May 2, 2024

Would it be better to make this part of the monitor rules? it would probably also fix this issue:

Also, technically if a new monitor is added after startup and it matches the name, then the cursor will be set to there.
To fix this you would need to make the code stop checking after startup or after all the initial monitors have been added.
I don't know how you would do that though

@vaxerski
Copy link
Member

vaxerski commented May 2, 2024

don't think so, because it can only match one monitor at a time, so there is no benefit to it being a rule.

@ikalco
Copy link
Contributor Author

ikalco commented May 2, 2024

I also saw that whenever a new window is created it doesn't follow where the mouse was.
Ex. mouse, by default, on left monitor, window created on right

Is that related?
Maybe the focus needs to be set as well?

Copy link
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

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

as it's getting quite large, I'd move it to a separate function e.g. static void checkDefaultCursorWarp or something

src/events/Monitors.cpp Outdated Show resolved Hide resolved
src/events/Monitors.cpp Outdated Show resolved Hide resolved
@vaxerski
Copy link
Member

vaxerski commented May 2, 2024

I also saw that whenever a new window is created it doesn't follow where the mouse was.

you should also g_pCompositor->setactivemonitor and g_pInputManager->refocus() for that

Copy link
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

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

lgtm, wiki mr needed

@ikalco
Copy link
Contributor Author

ikalco commented May 3, 2024

Does this work?
hyprwm/hyprland-wiki#627

@vaxerski vaxerski merged commit 387127b into hyprwm:main May 3, 2024
10 checks passed
@vaxerski
Copy link
Member

vaxerski commented May 3, 2024

thanks!

@ikalco ikalco deleted the default_monitor_cursor branch May 3, 2024 01:41
@ikalco ikalco restored the default_monitor_cursor branch May 3, 2024 01:42
@ikalco ikalco deleted the default_monitor_cursor branch May 6, 2024 13:33
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.

None yet

3 participants