Skip to content

Add the 'hold' feature as requested by #18 - #22

Merged
robiot merged 8 commits into
robiot:masterfrom
ctxnop:master
Mar 14, 2022
Merged

robiot merged 8 commits into
robiot:masterfrom
ctxnop:master

Conversation

@ctxnop

@ctxnop ctxnop commented Mar 13, 2022

Copy link
Copy Markdown
Contributor

Select the 'Hold' value in the 'Click type'. It disable widgets that
make no sense in such situation. Emits the 'mouse down' event on start,
and 'mouse up' on stop.

Signed-off-by: ctxnop ctxnop@gmail.com

Select the 'Hold' value in the 'Click type'. It disable widgets that
make no sense in such situation. Emits the 'mouse down' event on start,
and 'mouse up' on stop.

Signed-off-by: ctxnop <ctxnop@gmail.com>
Reworked a bit the switch/case handling in mouse_up/down functions for a
cleaner code. Removed a useless comment that I copy/pasted from the
Gtk's documentation.

Signed-off-by: ctxnop <ctxnop@gmail.com>
Comment thread src/x11api.c Outdated
@robiot

robiot commented Mar 13, 2022

Copy link
Copy Markdown
Owner

I can fix these since I'm kinda bored atm

As pointed out by @robiot there is no reason to have two almost
identical function where one function can handle both cases.

Signed-off-by: ctxnop <ctxnop@gmail.com>
@ctxnop

ctxnop commented Mar 13, 2022

Copy link
Copy Markdown
Contributor Author

I fixed it. Let me know if you see any other issue I can solve.

ctxnop and others added 4 commits March 13, 2022 21:52
Added the 'Hold' in the "Choose click type" feature item.

Signed-off-by: ctxnop <ctxnop@gmail.com>
Changed name of the MouseEvents items to reflect what it's doing. Also put click modes inside an enum
Instead of using the count variable which is for the repeat option
@robiot

robiot commented Mar 13, 2022

Copy link
Copy Markdown
Owner

LGTM. Will check again tomorrow and hopefully merge.
It would be good if there is any good way of running the press down event once and then skip the loop so it doesn't have to try to run it multiple times per second. But I can't really think of a way that is clean. So lets keep it like this for now :)

@ctxnop

ctxnop commented Mar 13, 2022

Copy link
Copy Markdown
Contributor Author

Yeah, I agree. I thought that the main thread could lock a mutex on start and release it on stop. So the "clicking" thread would lock the same mutex and be blocked until the main thread released it. But, to be honest, I added this feature because I needed it this afternoon for few hours only. So I didn't want to spend too much time on it. If you want me to implement something using locks, tell me, I'll propose you something soon.

Comment thread src/x11api.h Outdated
Comment on lines +21 to +22
MOUSE_EVENT_PRESS,
MOUSE_RELEASE,

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.

Feels a bit weird to me. Why there is a _EVENT_ part for press but not for release?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you for pointing that out. Didn't notice it.

@robiot robiot left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looks good now. Let me know if you find anything weird. I'll merge as soon possible.

Comment thread src/mainwin.c
g_thread_new("get_cursor_pos_handler", get_cursor_pos_handler, NULL);
}

void click_type_entry_changed()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Does not disable the Custom Location switch

@ctxnop ctxnop Mar 14, 2022 •

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, on purpose. I mean, I was wondering if it make sense. I didn't find any useful case but didn't want to prevent it as maybe someone has a use case I don't see.

I primarily implement this feature in few minutes because I was playing factorio and I needed something to hold the right click for me (which is mining resources) while I was away cooking (true story....). So I think it might make some sense in this context as I could set the custom location right under my character feets (almost screen center in this case) so that it gives me a hotkey to start mining whatever resource I'm on.

Comment thread src/x11api.h Outdated
Comment on lines +21 to +22
MOUSE_EVENT_PRESS,
MOUSE_RELEASE,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you for pointing that out. Didn't notice it.

@ctxnop ctxnop left a comment

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.

LGTM. Maybe adding some braces on if/else branches. I'm used to omit those but that may not fit your coding styles.

@robiot
robiot merged commit 39efa5d into robiot:master Mar 14, 2022
@robiot

robiot commented Mar 14, 2022

Copy link
Copy Markdown
Owner

Merging. Thank you very much.
Have a great day/night :)

robiot added a commit that referenced this pull request Oct 2, 2023
* Add the 'hold' feature as requested by #18

Select the 'Hold' value in the 'Click type'. It disable widgets that
make no sense in such situation. Emits the 'mouse down' event on start,
and 'mouse up' on stop.

Signed-off-by: ctxnop <ctxnop@gmail.com>

* Better case handling and removed a useless comment

Reworked a bit the switch/case handling in mouse_up/down functions for a
cleaner code. Removed a useless comment that I copy/pasted from the
Gtk's documentation.

Signed-off-by: ctxnop <ctxnop@gmail.com>

* Refactor the two mouse_up/down function into one

As pointed out by @robiot there is no reason to have two almost
identical function where one function can handle both cases.

Signed-off-by: ctxnop <ctxnop@gmail.com>

* Updated the README.md to add the new feature

Added the 'Hold' in the "Choose click type" feature item.

Signed-off-by: ctxnop <ctxnop@gmail.com>

* Minor naming fixes

Changed name of the MouseEvents items to reflect what it's doing. Also put click modes inside an enum

* Comment fix and formatting

* Use own variable for keeping track of if already holding

Instead of using the count variable which is for the repeat option

* Fix Enum item naming

Co-authored-by: Robiot <r0w80abc@gmail.com>
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