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

Showing the input during GUI usage #549

Merged
merged 35 commits into from
Nov 20, 2022
Merged

Showing the input during GUI usage #549

merged 35 commits into from
Nov 20, 2022

Conversation

sezanzeb
Copy link
Owner

@sezanzeb sezanzeb commented Nov 19, 2022

closes #546

  • Removed files accidentally merged in from main eff463e
  • tests can stop all debounced functions, or run them without waiting

image

The text on the bottom can be selected and copied. This is insanely useful

@sezanzeb sezanzeb changed the title Input hints Showing the input during GUI usage Nov 19, 2022
@sezanzeb sezanzeb marked this pull request as ready for review November 20, 2022 15:13
inputremapper/gui/autocompletion.py Outdated Show resolved Hide resolved
Comment on lines 484 to 488
@debounce(1000)
def _on_gtk_changed(self, *_):
# This triggers for each typed character, will cause disk-writes and writes
# tons of logs, so this is debounced a bit
self._controller.update_mapping(output_symbol=self.code)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it is a good idea do delay the mapping update. This will also delay all updates to other Gui components because they are not notified by the MessageBroker.

I know this has probably no impact at the moment because there are no other gui components which care about the output_symbol. But we might create some in the future.

What happens if the preset is changed before the function is called?

The controller is currently responsible for loading and saving presets. We can create a debounced save() method in the controller and use that to avoid excessive disk-writes.
The controller also knows when a new group or preset is loaded, so it can cancel the debounce and save the preset before loading a new one.

Copy link
Owner Author

@sezanzeb sezanzeb Nov 20, 2022

Choose a reason for hiding this comment

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

every single typed character writes

18:51:10.085774 44307 GUI DEBUG autocompletion.py:102: get_incomplete_parameter text: aa match: <re.Match object; span=(0, 2), match='aa'>
18:51:10.984839 44307 GUI DEBUG message_broker.py:71: from data_manager.py:128: Signal=mapping: {'event_combination': <EventCombination (1, 276, 1)>, 'target_uinput': 'keyboard', 'output_symbol': 'aa', 'mapping_type': 'key_macro'}
18:51:10.987010 44307 GUI DEBUG message_broker.py:71: from controller.py:619: Signal=status_msg: StatusData(ctx_id=5, msg='Mapping error at Button EXTRA, hover for info', tooltip='3 validation errors for Mapping\noutput_symbol\n The output_symbol "aa" is not a macro and not a valid keycode-name (type=value_error)\n__root__\n Missing Argument: Mapping must either contain output_symbol or output_type and output_code (type=value_error)\n__root__\n missing macro or key: "Button EXTRA" is not used as analog input, but no output macro or key is programmed (type=value_error)')
18:51:10.987373 44307 GUI INFO preset.py:184: Saving preset to /home/mango/.config/input-remapper/beta_1.6.0-beta/presets/USB Optical Mouse/a.json

to the logs

if there is a macro in there it gets a bit worse

19:11:19.329005 46039 GUI DEBUG message_broker.py:71: from data_manager.py:128: Signal=mapping: {'event_combination': <EventCombination (1, 276, 1)>, 'target_uinput': 'keyboard', 'output_symbol': 'repeat(5, key(ab))', 'mapping_type': 'key_macro'}
19:11:19.329296 46039 GUI DEBUG parse.py:455: parsing macro repeat(5, key(ab))
19:11:19.329618 46039 GUI DEBUG parse.py:455: parsing macro repeat(5, key(ab))
19:11:19.329931 46039 GUI DEBUG parse.py:455: parsing macro repeat(5, key(ab))
19:11:19.330687 46039 GUI DEBUG message_broker.py:71: from controller.py:619: Signal=status_msg: StatusData(ctx_id=5, msg='Mapping error at Button EXTRA, hover for info', tooltip='3 validation errors for Mapping\noutput_symbol\n Unknown key "ab" (type=value_error)\n__root__\n Missing Argument: Mapping must either contain output_symbol or output_type and output_code (type=value_error)\n__root__\n missing macro or key: "Button EXTRA" is not used as analog input, but no output macro or key is programmed (type=value_error)')
19:11:19.330871 46039 GUI INFO preset.py:184: Saving preset to /home/mango/.config/input-remapper/beta_1.6.0-beta/presets/USB Optical Mouse/a.json
19:11:19.331003 46039 GUI DEBUG parse.py:455: parsing macro repeat(5, key(ab))
19:11:19.431758 46039 GUI DEBUG autocompletion.py:102: get_incomplete_parameter text: repeat(5, key(ab match: <re.Match object; span=(0, 16), match='repeat(5, key(ab'>

when leaving the text input by interacting with any other gui component in any way, saving is tirggered immediately via _on_gtk_focus_out.

What happens if the preset is changed before the function is called?

I think most of the time nothing. I don't like both options now though

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah the MessageBroker is quite verbose debug_logging every single message. But using it less is the wrong "solution". Creating more debug levels seems more appropriate.

Copy link
Owner Author

@sezanzeb sezanzeb Nov 20, 2022

Choose a reason for hiding this comment

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

I pushed a change that prevents stuff from happening when the mapping changes (caused by a preset change), with tests, and reduced the time

are you still opposed?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'll make a separate PR and merge this without the debounce

inputremapper/gui/utils.py Outdated Show resolved Hide resolved
inputremapper/gui/utils.py Outdated Show resolved Hide resolved
inputremapper/gui/utils.py Outdated Show resolved Hide resolved
inputremapper/gui/utils.py Outdated Show resolved Hide resolved
inputremapper/gui/utils.py Outdated Show resolved Hide resolved
inputremapper/gui/utils.py Outdated Show resolved Hide resolved
inputremapper/gui/utils.py Outdated Show resolved Hide resolved
inputremapper/gui/utils.py Outdated Show resolved Hide resolved
inputremapper/gui/utils.py Outdated Show resolved Hide resolved
@sezanzeb sezanzeb merged commit d2fc5a6 into beta Nov 20, 2022
@sezanzeb sezanzeb deleted the input-hints branch March 2, 2023 15:57
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

2 participants