Skip to content

Commit

Permalink
fix issue where holding space when bespoke isn't focused would cause …
Browse files Browse the repository at this point in the history
…mouse movements to pan the canvas, and fix an issue where mouse wrap wouldn't pan on the 0 side if the window is fully maximized (BespokeSynth#1593)
  • Loading branch information
awwbees authored Jun 13, 2024
1 parent ed4ef4a commit 5f9c822
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions Source/ModularSynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ void ModularSynth::Poll()
}

bool shiftPressed = (GetKeyModifiers() == kModifier_Shift);
if (shiftPressed && !mIsShiftPressed)
if (shiftPressed && !mIsShiftPressed && IKeyboardFocusListener::GetActiveKeyboardFocus() == nullptr)
{
double timeBetweenPresses = gTime - mLastShiftPressTime;
if (timeBetweenPresses < 400)
Expand Down Expand Up @@ -1211,12 +1211,19 @@ void ModularSynth::MouseMoved(int intX, int intY)
mZoomer.CancelMovement();

if (UserPrefs.wrap_mouse_on_pan.Get() &&
(intX < 0 || intY < 0 || intX >= ofGetWidth() || intY >= ofGetHeight()))
(intX <= 0 || intY <= 0 || intX >= ofGetWidth() || intY >= ofGetHeight()))
{
int wrappedX = (intX + (int)ofGetWidth()) % (int)ofGetWidth();
int wrappedY = (intY + (int)ofGetHeight()) % (int)ofGetHeight();

if (intX == 0 && wrappedX == 0)
wrappedX = ofGetWidth() - 1;
if (intY == 0 && wrappedY == 0)
wrappedY = ofGetHeight() - 1;

Desktop::setMousePosition(juce::Point<int>(wrappedX + mMainComponent->getScreenX(),
wrappedY + mMainComponent->getScreenY()));

intX = wrappedX;
intY = wrappedY;
}
Expand Down
3 changes: 2 additions & 1 deletion Source/SynthGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@ bool IsKeyHeld(int key, int modifiers)
{
return IKeyboardFocusListener::GetActiveKeyboardFocus() == nullptr &&
KeyPress::isKeyCurrentlyDown(key) &&
GetKeyModifiers() == modifiers;
GetKeyModifiers() == modifiers &&
TheSynth->GetMainComponent()->hasKeyboardFocus(true);
}

int KeyToLower(int key)
Expand Down

0 comments on commit 5f9c822

Please sign in to comment.