Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 4407790

Browse files
committed
Formatting changes
* Removed extra private specifier since everything is already private here. Can be undone if it's felt this makes things less clear * Add separate static xwininput handler method and made HandleAllegroMouseInput non-static. Tweaked method comments a bit * Removed void argument from HandleAllegroMouseInput
1 parent 7c7ab2a commit 4407790

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

Managers/UInputMan.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ namespace RTE {
126126
poll_joystick();
127127

128128
#ifdef __unix__
129-
_xwin_input_handler = HandleAllegroMouseInput;
129+
_xwin_input_handler = XWinInputHandlerOverride;
130130
#endif
131131

132132
return 0;
@@ -1034,8 +1034,8 @@ namespace RTE {
10341034
events.push_back(e);
10351035
}
10361036

1037-
g_UInputMan.m_AllegroMousePreviousX = mouse_x;
1038-
g_UInputMan.m_AllegroMousePreviousY = mouse_y;
1037+
m_AllegroMousePreviousX = mouse_x;
1038+
m_AllegroMousePreviousY = mouse_y;
10391039
int mouseDeltaX = 0;
10401040
int mouseDeltaY = 0;
10411041

@@ -1044,13 +1044,13 @@ namespace RTE {
10441044
for (std::vector<XEvent>::reverse_iterator event = events.rbegin(); event < events.rend(); ++event) {
10451045
switch (event->type) {
10461046
case MotionNotify: {
1047-
mouseDeltaX = event->xmotion.x - g_UInputMan.m_AllegroMousePreviousX;
1048-
mouseDeltaY = event->xmotion.y - g_UInputMan.m_AllegroMousePreviousY;
1047+
mouseDeltaX = event->xmotion.x - m_AllegroMousePreviousX;
1048+
mouseDeltaY = event->xmotion.y - m_AllegroMousePreviousY;
10491049
_xwin_mouse_interrupt(mouseDeltaX, mouseDeltaY, 0, 0, mouse_b);
1050-
_mouse_x = g_UInputMan.m_AllegroMousePreviousX = !g_UInputMan.m_TrapMousePos ? event->xmotion.x : halfResX;
1051-
_mouse_y = g_UInputMan.m_AllegroMousePreviousY = !g_UInputMan.m_TrapMousePos ? event->xmotion.y : halfResY;
1050+
_mouse_x = m_AllegroMousePreviousX = !m_TrapMousePos ? event->xmotion.x : halfResX;
1051+
_mouse_y = m_AllegroMousePreviousY = !m_TrapMousePos ? event->xmotion.y : halfResY;
10521052

1053-
if (g_UInputMan.m_TrapMousePos && (mouseDeltaX != 0 || mouseDeltaY != 0)) {
1053+
if (m_TrapMousePos && (mouseDeltaX != 0 || mouseDeltaY != 0)) {
10541054
XWarpPointer(_xwin.display, _xwin.window, _xwin.window, 0, 0, 0, 0, halfResX, halfResY);
10551055
}
10561056
break;
@@ -1067,7 +1067,7 @@ namespace RTE {
10671067
_xwin.mouse_warped = 0;
10681068
_xwin_private_handle_input();
10691069

1070-
if (g_UInputMan.m_TrapMousePos) {
1070+
if (m_TrapMousePos) {
10711071
mouse_x = _xwin.window_width / 2;
10721072
mouse_y = _xwin.window_height / 2;
10731073
}

Managers/UInputMan.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -797,18 +797,20 @@ namespace RTE {
797797
UInputMan & operator=(const UInputMan &rhs) = delete;
798798

799799
#ifdef __unix__
800-
private:
801-
802800
int m_AllegroMousePreviousX; //!< Stored mouse x position for the allegro event handler.
803801
int m_AllegroMousePreviousY; //!< Stored mouse y position for the allegro event handler.
804802

803+
/// <summary>
804+
/// Necessary static handler method ensuring mouse inputs work well on Linux. Must be applied to _xwin_input_handler when manager is initialized.
805+
/// </summary>
806+
static void XWinInputHandlerOverride() { g_UInputMan.HandleAllegroMouseInput(); }
807+
805808
/// <summary>
806809
/// Mouse input handler to circumvent the input drops that allegro does regularly, by replacing and disabling the default warping behaviour.
807810
/// Motion events that are generated while the handler is working are offset such that the allegro driver doesn't mess up the mickeys.
808-
/// This also handles the centering warp for relative mouse motion.
809-
/// Should be applied to _xwin_input_handler. Might not run in the main thread, depending on how allegro was built.
811+
/// This also handles the centering warp for relative mouse motion. Might not run in the main thread, depending on how allegro was built.
810812
/// </summary>
811-
static void HandleAllegroMouseInput(void);
813+
void HandleAllegroMouseInput();
812814

813815
/// <summary>
814816
/// Position the mouse on the screen in window coordinates. Generates MouseMotion events if the requested position is different from the actual mouse position.

0 commit comments

Comments
 (0)