Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/aux_vis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1356,8 +1356,9 @@ void KeyCtrlP()
#endif
}

void KeyQPressed()
void KeyQPressed(SDL_Keymod state)
{
if (state & KMOD_SHIFT) { return Window::SwitchSolution(); }
wnd->signalQuit();
visualize = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/aux_vis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void TouchPinch(SDL_MultiGestureEvent & e);

void KeyCtrlP();
void KeyS();
void KeyQPressed();
void KeyQPressed(SDL_Keymod);
void ToggleThreads();
void ThreadsPauseFunc(SDL_Keymod);
void ThreadsStop();
Expand Down
6 changes: 5 additions & 1 deletion lib/glwindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,15 @@ class GLWindow
void setOnIdle(IdleDelegate func) { onIdle = func; }
void setOnExpose(Delegate func) { onExpose = func; }

void setOnKeyDown(SDL_Keycode key, KeyDelegate func)
{
onKeyDown[key] = [func](SDL_Keymod) { func(SDL_GetModState()); };
}
Comment on lines +98 to +101
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not to pass the argument there? There have been historically problems with SDL_GetModState(), I think.

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.

I tried, but it is clamped to KMOD_NONE (0).

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.

the SdlWindow::mouseEvents seems to use it too.

Copy link
Copy Markdown
Contributor

@najlkin najlkin Jan 30, 2026

Choose a reason for hiding this comment

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

Well, with mouse it is easy, but with keys it is more complicated, because some layouts need modifiers for keys to be translated and then the modifier is removed. But worse, there has been some platform specific behavior of the function, I think 🤔 .


void setOnKeyDown(SDL_Keycode key, Delegate func)
{
onKeyDown[key] = [func](SDL_Keymod) { func(); };
}
void setOnKeyDown(SDL_Keycode key, KeyDelegate func) { onKeyDown[key] = func; }

void setOnMouseDown(SDL_Mousebutton btn, MouseDelegate func) { onMouseDown[btn] = func; }
void setOnMouseUp(SDL_Mousebutton btn, MouseDelegate func) { onMouseUp[btn] = func; }
Expand Down
6 changes: 6 additions & 0 deletions lib/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,9 @@ void Window::SwitchQuadSolution()
locwin->SwitchQuadSolution((DataState::QuadSolution)iqs);
SendExposeEvent();
}

void Window::SwitchSolution()
{
if (locwin->data_state.cgrid_f) { SwitchComplexSolution(); }
if (locwin->data_state.quad_f) { SwitchQuadSolution(); }
}
4 changes: 4 additions & 0 deletions lib/window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ struct Window
/// @note: Use with caution when the update is compatible
/// @see SetNewMeshAndSolution()
void ResetMeshAndSolution(DataState &ss);

public:
/// Switch the function representation for key handlers
static void SwitchSolution();
};

#endif // GLVIS_WINDOW_HPP
Loading