void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y) { rdpSettings* settings; if (!xfc || !xfc->context.settings || !y || !x) return; settings = xfc->context.settings; if (!xfc->remote_app) { #ifdef WITH_XRENDER if (xf_picture_transform_required(xfc)) { double xScalingFactor = settings->DesktopWidth / (double)xfc->scaledWidth; double yScalingFactor = settings->DesktopHeight / (double)xfc->scaledHeight; *x = (int)((*x - xfc->offset_x) * xScalingFactor); *y = (int)((*y - xfc->offset_y) * yScalingFactor); } #endif } CLAMP_COORDINATES(*x, *y); }
void xf_event_adjust_coordinates(xfContext* xfc, int* x, int *y) { if (!xfc->remote_app) { #ifdef WITH_XRENDER if (xf_picture_transform_required(xfc)) { double xScalingFactor = xfc->width / (double)xfc->scaledWidth; double yScalingFactor = xfc->height / (double)xfc->scaledHeight; *x = (int)((*x - xfc->offset_x) * xScalingFactor); *y = (int)((*y - xfc->offset_y) * yScalingFactor); } #endif } CLAMP_COORDINATES(*x, *y); }
BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window window, BOOL app) { rdpInput* input; Window childWindow; input = xfc->instance->input; if (!xfc->settings->MouseMotion) { if ((state & (Button1Mask | Button2Mask | Button3Mask)) == 0) return TRUE; } if (app) { /* make sure window exists */ if (xf_rdpWindowFromWindow(xfc, window) == 0) { return TRUE; } /* Translate to desktop coordinates */ XTranslateCoordinates(xfc->display, window, RootWindowOfScreen(xfc->screen), x, y, &x, &y, &childWindow); } /* Take scaling in to consideration */ if ( (xfc->settings->ScalingFactor != 1.0) || (xfc->offset_x) || (xfc->offset_y) ) { x = (int)((x - xfc->offset_x) * (1.0 / xfc->settings->ScalingFactor) ); y = (int)((y - xfc->offset_y) * (1.0 / xfc->settings->ScalingFactor) ); } CLAMP_COORDINATES(x,y); input->MouseEvent(input, PTR_FLAGS_MOVE, x, y); if (xfc->fullscreen) { XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot, CurrentTime); } return TRUE; }
BOOL xf_generic_ButtonRelease(xfContext* xfc, int x, int y, int button, Window window, BOOL app) { int flags; BOOL wheel; BOOL extended; rdpInput* input; Window childWindow; flags = 0; wheel = FALSE; extended = FALSE; input = xfc->instance->input; switch (button) { case 1: flags = PTR_FLAGS_BUTTON1; break; case 2: flags = PTR_FLAGS_BUTTON3; break; case 3: flags = PTR_FLAGS_BUTTON2; break; case 6: case 8: case 97: extended = TRUE; flags = PTR_XFLAGS_BUTTON1; break; case 7: case 9: case 112: extended = TRUE; flags = PTR_XFLAGS_BUTTON2; break; default: flags = 0; break; } if (flags != 0) { if (app) { /* make sure window exists */ if (xf_rdpWindowFromWindow(xfc, window) == NULL) { return TRUE; } /* Translate to desktop coordinates */ XTranslateCoordinates(xfc->display, window, RootWindowOfScreen(xfc->screen), x, y, &x, &y, &childWindow); } if ((xfc->settings->ScalingFactor != 1.0) || (xfc->offset_x) || (xfc->offset_y)) { x = (int) ((x - xfc->offset_x) * (1.0 / xfc->settings->ScalingFactor)); y = (int) ((y - xfc->offset_y) * (1.0 / xfc->settings->ScalingFactor)); } CLAMP_COORDINATES(x,y); if (extended) input->ExtendedMouseEvent(input, flags, x, y); else input->MouseEvent(input, flags, x, y); } return TRUE; }
BOOL xf_generic_ButtonPress(xfContext* xfc, int x, int y, int button, Window window, BOOL app) { int flags; BOOL wheel; BOOL extended; rdpInput* input; Window childWindow; flags = 0; wheel = FALSE; extended = FALSE; input = xfc->instance->input; switch (button) { case 1: flags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1; break; case 2: flags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON3; break; case 3: flags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2; break; case 4: wheel = TRUE; flags = PTR_FLAGS_WHEEL | 0x0078; break; case 5: wheel = TRUE; flags = PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0088; break; case 6: /* wheel left or back */ case 8: /* back */ case 97: /* Xming */ extended = TRUE; flags = PTR_XFLAGS_DOWN | PTR_XFLAGS_BUTTON1; break; case 7: /* wheel right or forward */ case 9: /* forward */ case 112: /* Xming */ extended = TRUE; flags = PTR_XFLAGS_DOWN | PTR_XFLAGS_BUTTON2; break; default: x = 0; y = 0; flags = 0; break; } if (flags != 0) { if (wheel) { input->MouseEvent(input, flags, 0, 0); } else { if (app) { /* make sure window exists */ if (xf_rdpWindowFromWindow(xfc, window) == 0) { return TRUE; } /* Translate to desktop coordinates */ XTranslateCoordinates(xfc->display, window, RootWindowOfScreen(xfc->screen), x, y, &x, &y, &childWindow); } if ((xfc->settings->ScalingFactor != 1.0) || (xfc->offset_x) || (xfc->offset_y)) { x = (int) ((x - xfc->offset_x) * (1.0 / xfc->settings->ScalingFactor)); y = (int) ((y - xfc->offset_y) * (1.0 / xfc->settings->ScalingFactor)); } CLAMP_COORDINATES(x,y); if (extended) input->ExtendedMouseEvent(input, flags, x, y); else input->MouseEvent(input, flags, x, y); } } return TRUE; }