CuarzoSoftware / Louvre

C++ library for building Wayland compositors.
MIT License
506 stars 14 forks source link

Customizing Shortcuts Definition #59

Closed milisarge closed 2 months ago

milisarge commented 2 months ago

When i look at the F1 key, it is predefined with weston-terminal (https://github.com/CuarzoSoftware/Louvre/blob/980bf1a06db95b94b22e46e07ffb25f15380129e/src/lib/core/default/LKeyboardDefault.cpp#L47),

If i want to re-define it with my terminal application, which way is the proper way of doing it?

By the way, i am using Louvre core library, just curious why keyboard definitions are embed in the core library?

milisarge commented 2 months ago

I forked my project from loure-views, i defined the key in Keyboard.cpp but it also triggers core definition, my terminal app and weston-terminal are opening at the same time when i press F1 :) i would like to modify without hacking the core lib.

Fox2Code commented 2 months ago

Louvre View should have disabled F1 key from this from this:

https://github.com/CuarzoSoftware/Louvre/blob/main/src/examples/louvre-views/src/Keyboard.cpp https://github.com/CuarzoSoftware/Louvre/blob/main/src/examples/louvre-views/src/Compositor.cpp#L142

This is weird, definitely needs more investigating.

ehopperdietzel commented 2 months ago

There are custom flags you can pass to LScene event handlers. Check LScene::handleKeyboardKeyEvent(), so you don't have to write it yourself.

By default, all are set. In this case, you should remove the AuxFunc flag.

scene.handleKeyboardKeyEvent(event, LScene::WaylandEvents);

Keep in mind that other shortcuts, such as exiting the compositor with Ctrl + Shift + Esc, will also be disabled.

Here is the default implementation: LKeyboard::keyEvent()

Fox2Code commented 2 months ago

I think this detail should be added to the base tutorial/documentation.

ehopperdietzel commented 2 months ago

It is https://github.com/CuarzoSoftware/LouvreTemplate/blob/main/src/utils/Settings.h

milisarge commented 2 months ago

Sorry, i could not follow how can i overwriting the F1 key binding by using LScene::handleKeyboardKeyEvent

ehopperdietzel commented 2 months ago

You need to explicitly set LScene::WaylandEvents as the second argument of LScene::handleKeyboardKeyEvent().