Skip to content

Commit

Permalink
Restore mouse support to orbits window
Browse files Browse the repository at this point in the history
The old mouse code worked by faking up key presses for all the mouse
movements.  We want to move away from this style of mouse handling and
move towards handling mouse events directly.  The orbit window handling
would block waiting for keyboard input through the cursor.  Our indirect
method of handling mouse events updates the cursor position, so add a
flag on the Cursor object that unblocks waiting for a key press if the
position was updated externally.  This unblocks the Cursor key press
code once and allows the orbits window to continue.
  • Loading branch information
LegalizeAdulthood committed Jan 21, 2025
1 parent a06f150 commit bc2a4ff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
14 changes: 7 additions & 7 deletions libid/engine/jiim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1194,20 +1194,20 @@ bool InverseJulia::iterate()
{
bool still{true};
bool mouse_updated{};
if (m_actively_computing)
if (s_cursor.get_x() != g_col || s_cursor.get_y() != g_row)
{
g_col = s_cursor.get_x();
g_row = s_cursor.get_y();
mouse_updated = true;
}
if (m_actively_computing || mouse_updated)
{
s_cursor.check_blink();
}
else
{
s_cursor.wait_key();
}
if (s_cursor.get_x() != g_col || s_cursor.get_y() != g_row)
{
g_col = s_cursor.get_x();
g_row = s_cursor.get_y();
mouse_updated = true;
}
if (driver_key_pressed() || m_first_time || mouse_updated)
{
m_first_time = false;
Expand Down
1 change: 1 addition & 0 deletions libid/include/ui/editpal.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class CrossHairCursor
int m_hidden; // >0 if mouse hidden
long m_last_blink;
bool m_blink;
bool m_pos_updated{};
char m_top[CURSOR_SIZE]; // save line segments here
char m_bottom[CURSOR_SIZE];
char m_left[CURSOR_SIZE];
Expand Down
4 changes: 3 additions & 1 deletion libid/ui/editpal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ void CrossHairCursor::set_pos(int x, int y)

m_x = x;
m_y = y;
m_pos_updated = true;

if (!m_hidden)
{
Expand Down Expand Up @@ -1170,10 +1171,11 @@ void CrossHairCursor::check_blink()

int CrossHairCursor::wait_key()
{
while (!driver_wait_key_pressed(true))
while (!driver_wait_key_pressed(true) && !m_pos_updated)
{
check_blink();
}
m_pos_updated = false;

return driver_key_pressed();
}
Expand Down

0 comments on commit bc2a4ff

Please sign in to comment.