Changeset View
Standalone View
source/gui/CGUI.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | InReaction CGUI::HandleEvent(const SDL_Event_* ev) | ||||
{ | { | ||||
const char* hotkey = static_cast<const char*>(ev->ev.user.data1); | const char* hotkey = static_cast<const char*>(ev->ev.user.data1); | ||||
std::map<CStr, std::vector<IGUIObject*> >::iterator it = m_HotkeyObjects.find(hotkey); | std::map<CStr, std::vector<IGUIObject*> >::iterator it = m_HotkeyObjects.find(hotkey); | ||||
if (it != m_HotkeyObjects.end()) | if (it != m_HotkeyObjects.end()) | ||||
for (IGUIObject* const& obj : it->second) | for (IGUIObject* const& obj : it->second) | ||||
{ | { | ||||
// Update hotkey status before sending the event, | // Update hotkey status before sending the event, | ||||
// else the status will be outdated when processing the GUI event. | // else the status will be outdated when processing the GUI event. | ||||
wraitii: This copies the string every time, which is rather unlucky for performance.
You can either go… | |||||
HotkeyInputHandler(ev); | HotkeyInputHandler(ev); | ||||
ret = IN_HANDLED; | ret = IN_HANDLED; | ||||
if (ev->ev.type == SDL_HOTKEYDOWN) | // On keydown send 1 or 2 messages depending on repeat flag. This does not work on linux | ||||
// for special keys (shift, alt, ctrl), since the linux keyboard event manager sends the KEYDOWN only once. | |||||
Done Inline ActionsPeriod after flag. elexis: Period after flag.
I guess it's not the kernel sending the keydown events. Not sure if it isnt… | |||||
Not Done Inline Actionsalready have the ticket #4915 bb: already have the ticket #4915 | |||||
Not Done Inline Actions
This statement can't be verified or corrected by only considering our code. elexis: > since the linux keyboard event manager sends the KEYDOWN only once.
This statement can't be… | |||||
Not Done Inline Actionsbb: https://github.com/SFML/SFML/issues/122 | |||||
if (ev->ev.type == SDL_HOTKEYDOWN && (int)ev->ev.user.data2 == 0) | |||||
elexisUnsubmitted Not Done Inline Actions(The int conversion is needed because data2 is a void pointer and those should have a type before they are compared to an int?) elexis: (The int conversion is needed because `data2` is a void pointer and those should have a type… | |||||
bbAuthorUnsubmitted Not Done Inline Actionsnot needed indeed bb: not needed indeed | |||||
elexisUnsubmitted Not Done Inline ActionsI actually don't know. Maybe clang or some other compiler complains. Should do what similar code does. elexis: I actually don't know. Maybe clang or some other compiler complains. Should do what similar… | |||||
Not Done Inline ActionsDo we use SFML as well I thought we only used SDL ? Stan: Do we use SFML as well I thought we only used SDL ? | |||||
Done Inline Actionswe use SDL indeed, but this is not an SDL issue, it most likely is a linux kernel issue bb: we use SDL indeed, but this is not an SDL issue, it most likely is a linux kernel issue | |||||
obj->SendEvent(GUIM_PRESSED, "press"); | obj->SendEvent(GUIM_PRESSED, "press"); | ||||
elexisUnsubmitted Done Inline Actions(\n?) elexis: (\n?) | |||||
if (ev->ev.type == SDL_HOTKEYDOWN) | |||||
obj->SendEvent(GUIM_PRESSED, "keydown"); | |||||
else | else | ||||
obj->SendEvent(GUIM_RELEASED, "release"); | obj->SendEvent(GUIM_RELEASED, "release"); | ||||
Not Done Inline ActionsThis isn't consistent with global hotkeys. If we are passing an event name, why is the event always GUIM_PRESSED? wraitii: This isn't consistent with global hotkeys. If we are passing an event name, why is the event… | |||||
Done Inline ActionsInconsistency with globalhotkeys not introduced in this patch GUIM_PRESSED => I am stupid bb: Inconsistency with globalhotkeys not introduced in this patch
GUIM_PRESSED => I am stupid | |||||
} | } | ||||
} | } | ||||
else if (ev->ev.type == SDL_MOUSEMOTION) | else if (ev->ev.type == SDL_MOUSEMOTION) | ||||
{ | { | ||||
// Yes the mouse position is stored as float to avoid | // Yes the mouse position is stored as float to avoid | ||||
// constant conversions when operating in a | // constant conversions when operating in a | ||||
// float-based environment. | // float-based environment. | ||||
▲ Show 20 Lines • Show All 1,650 Lines • Show Last 20 Lines |
This copies the string every time, which is rather unlucky for performance.
You can either go with a double-ternary, or a function returning a constant reference.
The double-ternary is probably easier, both compile to the same code anyways:
See https://godbolt.org/z/dI82LT