Skip to content

Commit

Permalink
Merge pull request #1626 from Hoikas/fix_1620
Browse files Browse the repository at this point in the history
Fix #1620
  • Loading branch information
Hoikas authored Nov 14, 2024
2 parents 0352749 + cf3c86b commit 61175a8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
17 changes: 9 additions & 8 deletions Sources/Plasma/Apps/plClient/Mac-Cocoa/PLSView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,19 @@ - (void)updateClientMouseLocation:(NSEvent*)event
CGPoint viewLocation = [self convertPoint:windowLocation fromView:nil];

NSRect windowViewBounds = self.bounds;
CGFloat deltaX = (windowLocation.x) / windowViewBounds.size.width;
CGFloat deltaY =
CGFloat xNormal = (windowLocation.x) / windowViewBounds.size.width;
CGFloat yNormal =
(windowViewBounds.size.height - windowLocation.y) / windowViewBounds.size.height;

plIMouseXEventMsg* pXMsg = new plIMouseXEventMsg;
plIMouseYEventMsg* pYMsg = new plIMouseYEventMsg;

pXMsg->fWx = viewLocation.x;
pXMsg->fX = deltaX;
pXMsg->fX = xNormal;
pYMsg->fY = yNormal;

pYMsg->fWy = (windowViewBounds.size.height - windowLocation.y);
pYMsg->fY = deltaY;
// Plasma internally uses input coords as display coords
pXMsg->fWx = viewLocation.x * self.window.screen.backingScaleFactor;
pYMsg->fWy = (windowViewBounds.size.height - windowLocation.y) * self.window.screen.backingScaleFactor;

@synchronized(self.layer) {
if (self.inputManager) {
Expand All @@ -219,7 +220,7 @@ - (void)updateClientMouseLocation:(NSEvent*)event
newWindowLocation.x = CGRectGetMidX(self.window.contentView.bounds);

// macOS won't generate a new message on warp, need to tell Plasma by hand
pXMsg->fWx = newWindowLocation.x;
pXMsg->fWx = newWindowLocation.x * self.window.screen.backingScaleFactor;;
pXMsg->fX = 0.5f;
self.inputManager->MsgReceive(pXMsg);
}
Expand All @@ -228,7 +229,7 @@ - (void)updateClientMouseLocation:(NSEvent*)event
newWindowLocation.y = CGRectGetMidY(self.window.contentView.bounds);

// macOS won't generate a new message on warp, need to tell Plasma by hand
pYMsg->fWy = newWindowLocation.y;
pYMsg->fWy = newWindowLocation.y * self.window.screen.backingScaleFactor;;
pYMsg->fY = 0.5f;
self.inputManager->MsgReceive(pYMsg);
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Plasma/PubUtilLib/plInputCore/plInputDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ bool plMouseDevice::MsgReceive(plMessage* msg)
fXPos = pXMsg->fX;

SetCursorX(fXPos);
fWXPos = pXMsg->fWx * fScale;
fWXPos = pXMsg->fWx;
return true;
}

Expand Down Expand Up @@ -529,7 +529,7 @@ bool plMouseDevice::MsgReceive(plMessage* msg)
else
fYPos = pYMsg->fY;

fWYPos = pYMsg->fWy * fScale;
fWYPos = pYMsg->fWy;
SetCursorY(fYPos);

return true;
Expand Down
11 changes: 7 additions & 4 deletions Sources/Plasma/PubUtilLib/plInputCore/plInputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// plInputManager.cpp
#include "HeadSpin.h"
#include "hsWindows.h"
#ifdef WIN32
# include <Windowsx.h>
#endif

#include "plInputManager.h"
#include "plPipeline.h"
Expand Down Expand Up @@ -294,10 +297,10 @@ void plInputManager::HandleWin32ControlEvent(UINT message, WPARAM Wparam, LPARAM
plIMouseYEventMsg* pYMsg = new plIMouseYEventMsg;
plIMouseBEventMsg* pBMsg = new plIMouseBEventMsg;

pXMsg->fWx = LOWORD(Lparam);
pXMsg->fX = (float)LOWORD(Lparam) / (float)rect.right;
pYMsg->fWy = HIWORD(Lparam);
pYMsg->fY = (float)HIWORD(Lparam) / (float)rect.bottom;
pXMsg->fWx = GET_X_LPARAM(Lparam);
pXMsg->fX = (float)GET_X_LPARAM(Lparam) / (float)rect.right;
pYMsg->fWy = GET_Y_LPARAM(Lparam);
pYMsg->fY = (float)GET_Y_LPARAM(Lparam) / (float)rect.bottom;

// Apply mouse scale
// pXMsg->fX *= fMouseScale;
Expand Down

0 comments on commit 61175a8

Please sign in to comment.