mirror of https://github.com/FreeRDP/FreeRDP
MacFreeRDP: Handling of mouse and region invalidation on scaling/scrolling
This commit is contained in:
parent
27750e7022
commit
78981418ce
|
@ -48,7 +48,6 @@
|
|||
NSTimer* pasteboard_timer;
|
||||
NSCursor* currentCursor;
|
||||
NSRect prevWinPosition;
|
||||
int titleBarHeight;
|
||||
freerdp* instance;
|
||||
rdpContext* context;
|
||||
CGContextRef bitmap_context;
|
||||
|
@ -86,8 +85,7 @@
|
|||
|
||||
- (int) rdpStart :(rdpContext*) rdp_context;
|
||||
- (void) setCursor: (NSCursor*) cursor;
|
||||
- (void) setScrollOffset:(int)xOffset y:(int)yOffset;
|
||||
- (void) sendMouseEvent:(UINT16) flags withX:(UINT16)x withY:(UINT16)y;
|
||||
- (void) setScrollOffset:(int)xOffset y:(int)yOffset w:(int)width h:(int)height;
|
||||
|
||||
- (void) onPasteboardTimerFired :(NSTimer *) timer;
|
||||
- (void) releaseResources;
|
||||
|
|
|
@ -147,6 +147,8 @@ struct rgba_data
|
|||
instance->settings->DesktopHeight = screenFrame.size.height;
|
||||
}
|
||||
|
||||
mfc->client_height = instance->settings->DesktopHeight;
|
||||
mfc->client_width = instance->settings->DesktopWidth;
|
||||
|
||||
mfc->thread = CreateThread(NULL, 0, mac_client_thread, (void*) context, 0, &mfc->mainThreadId);
|
||||
|
||||
|
@ -272,12 +274,6 @@ DWORD mac_client_thread(void* param)
|
|||
{
|
||||
if (!initialized)
|
||||
{
|
||||
// store our window dimensions
|
||||
titleBarHeight = 22;
|
||||
|
||||
[[self window] becomeFirstResponder];
|
||||
[[self window] setAcceptsMouseMovedEvents:YES];
|
||||
|
||||
cursors = [[NSMutableArray alloc] initWithCapacity:10];
|
||||
|
||||
// setup a mouse tracking area
|
||||
|
@ -750,14 +746,13 @@ DWORD mac_client_thread(void* param)
|
|||
}
|
||||
}
|
||||
|
||||
- (void) setScrollOffset:(int)xOffset y:(int)yOffset
|
||||
- (void) setScrollOffset:(int)xOffset y:(int)yOffset w:(int)width h:(int)height
|
||||
{
|
||||
if (xOffset != mfc->xCurrentScroll || yOffset != mfc->yCurrentScroll)
|
||||
{
|
||||
NSLog(@"setScrollOffset h:%d v:%d", xOffset, yOffset);
|
||||
mfc->yCurrentScroll = yOffset;
|
||||
mfc->xCurrentScroll = xOffset;
|
||||
}
|
||||
NSLog(@"setScrollOffset x:%d y:%d w:%d h:%d", xOffset, yOffset, width, height);
|
||||
mfc->yCurrentScroll = yOffset;
|
||||
mfc->xCurrentScroll = xOffset;
|
||||
mfc->client_height = height;
|
||||
mfc->client_width = width;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
|
@ -1101,8 +1096,8 @@ void mac_end_paint(rdpContext* context)
|
|||
|
||||
int ww, wh, dw, dh;
|
||||
|
||||
ww = [view frame].size.width;
|
||||
wh = [view frame].size.height;
|
||||
ww = mfc->client_width;
|
||||
wh = mfc->client_height;
|
||||
dw = mfc->context.settings->DesktopWidth;
|
||||
dh = mfc->context.settings->DesktopHeight;
|
||||
|
||||
|
@ -1124,6 +1119,10 @@ void mac_end_paint(rdpContext* context)
|
|||
drawRect.size.width = gdi->primary->hdc->hwnd->cinvalid[i].w + 1;
|
||||
drawRect.size.height = gdi->primary->hdc->hwnd->cinvalid[i].h + 1;
|
||||
|
||||
NSLog(@"drawRect x:%d y:%d w:%d h:%d", (int) drawRect.origin.x, (int) drawRect.origin.y, (int) drawRect.size.width, (int) drawRect.size.height);
|
||||
|
||||
windows_to_apple_cords(mfc->view, &drawRect);
|
||||
|
||||
if (mfc->context.settings->SmartSizing && (ww != dw || wh != dh))
|
||||
{
|
||||
drawRect.origin.y = drawRect.origin.y * wh / dh;
|
||||
|
@ -1132,9 +1131,10 @@ void mac_end_paint(rdpContext* context)
|
|||
drawRect.size.width = drawRect.size.width * ww / dw;
|
||||
}
|
||||
|
||||
windows_to_apple_cords(mfc->view, &drawRect);
|
||||
// Note: The xCurrentScroll and yCurrentScroll values do not need to be taken into account
|
||||
// because the current frame is always at full size, since the scrolling is handled by the external container.
|
||||
|
||||
[view setNeedsDisplayInRect:drawRect];
|
||||
[view setNeedsDisplayInRect:drawRect];
|
||||
}
|
||||
|
||||
gdi->primary->hdc->hwnd->ninvalid = 0;
|
||||
|
@ -1394,16 +1394,6 @@ void cliprdr_process_cb_format_list_event(freerdp* instance, RDP_CB_FORMAT_LIST_
|
|||
}
|
||||
}
|
||||
|
||||
- (void) sendMouseEvent:(UINT16) flags withX:(UINT16)x withY:(UINT16)y
|
||||
{
|
||||
y = instance->settings->DesktopHeight - y + mfc->yCurrentScroll;
|
||||
|
||||
x = x + mfc->xCurrentScroll;
|
||||
|
||||
// send mouse motion event to RDP server
|
||||
mf_scale_mouse_event(context, instance->input, PTR_FLAGS_MOVE, x, y);
|
||||
}
|
||||
|
||||
void process_cliprdr_event(freerdp* instance, wMessage* event)
|
||||
{
|
||||
if (event)
|
||||
|
|
|
@ -196,19 +196,35 @@ void freerdp_client_mouse_event(rdpContext* cfc, DWORD flags, int x, int y)
|
|||
void mf_scale_mouse_event(void* context, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
||||
{
|
||||
mfContext* mfc = (mfContext*) context;
|
||||
MRDPView* view = (MRDPView*) mfc->view;
|
||||
|
||||
int ww, wh, dw, dh;
|
||||
|
||||
ww = [view frame].size.width;
|
||||
wh = [view frame].size.height;
|
||||
ww = mfc->client_width;
|
||||
wh = mfc->client_height;
|
||||
dw = mfc->context.settings->DesktopWidth;
|
||||
dh = mfc->context.settings->DesktopHeight;
|
||||
|
||||
NSLog(@"mouse event ww:%d wh:%d dw:%d dh:%d xScroll:%d yScroll:%d x1:%d y1:%d",
|
||||
ww, wh, dw, dh, mfc->xCurrentScroll, mfc->yCurrentScroll, x, y);
|
||||
|
||||
if (!mfc->context.settings->SmartSizing || ((ww == dw) && (wh == dh)))
|
||||
input->MouseEvent(input, flags, x + mfc->xCurrentScroll, y + mfc->yCurrentScroll);
|
||||
{
|
||||
y = y + mfc->yCurrentScroll;
|
||||
|
||||
if (wh != dh)
|
||||
{
|
||||
y -= (dh - wh);
|
||||
}
|
||||
|
||||
NSLog(@"(scale off) -> input->MouseEvent(%d, %d)", x + mfc->xCurrentScroll, y);
|
||||
input->MouseEvent(input, flags, x + mfc->xCurrentScroll, y);
|
||||
}
|
||||
else
|
||||
input->MouseEvent(input, flags, x * dw / ww + mfc->xCurrentScroll, y * dh / wh + mfc->yCurrentScroll);
|
||||
{
|
||||
y = y * dh / wh + mfc->yCurrentScroll;
|
||||
NSLog(@"(scale on) -> input->MouseEvent(%d, %d)", x * dw / ww + mfc->xCurrentScroll, y);
|
||||
input->MouseEvent(input, flags, x * dw / ww + mfc->xCurrentScroll, y);
|
||||
}
|
||||
}
|
||||
|
||||
int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
|
||||
|
|
|
@ -40,6 +40,8 @@ struct mf_context
|
|||
char window_title[64];
|
||||
int client_x;
|
||||
int client_y;
|
||||
int client_width;
|
||||
int client_height;
|
||||
|
||||
HANDLE keyboardThread;
|
||||
HANDLE stopEvent;
|
||||
|
|
Loading…
Reference in New Issue