static BOOL xf_event_MotionNotify(xfInfo* xfi, XEvent* event, BOOL app) { int x, y; rdpInput* input; Window childWindow; input = xfi->instance->input; x = event->xmotion.x; y = event->xmotion.y; if (!xfi->settings->MouseMotion) { if ((event->xmotion.state & (Button1Mask | Button2Mask | Button3Mask)) == 0) return TRUE; } if (app) { /* make sure window exists */ if (xf_rdpWindowFromWindow(xfi, event->xmotion.window) == 0) { return TRUE; } /* Translate to desktop coordinates */ XTranslateCoordinates(xfi->display, event->xmotion.window, RootWindowOfScreen(xfi->screen), x, y, &x, &y, &childWindow); } if (xfi->scale != 1.0) { /* Take scaling in to consideration */ x = (int) (x * (1.0 / xfi->scale)); y = (int) (y * (1.0 / xfi->scale)); } input->MouseEvent(input, PTR_FLAGS_MOVE, x, y); if (xfi->fullscreen) { XSetInputFocus(xfi->display, xfi->window->handle, RevertToPointerRoot, CurrentTime); } return TRUE; }
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; }
static BOOL xf_event_PropertyNotify(xfInfo* xfi, XEvent* event, BOOL app) { /* * This section handles sending the appropriate commands to the rail server * when the window has been minimized, maximized, restored locally * ie. not using the buttons on the rail window itself */ if (app) { rdpWindow* window; window = xf_rdpWindowFromWindow(xfi, event->xproperty.window); if (window == NULL) return TRUE; if ((((Atom) event->xproperty.atom == xfi->_NET_WM_STATE) && (event->xproperty.state != PropertyDelete)) || (((Atom) event->xproperty.atom == xfi->WM_STATE) && (event->xproperty.state != PropertyDelete))) { int i; BOOL status; BOOL maxVert = FALSE; BOOL maxHorz = FALSE; BOOL minimized = FALSE; unsigned long nitems; unsigned long bytes; unsigned char* prop; if ((Atom) event->xproperty.atom == xfi->_NET_WM_STATE) { status = xf_GetWindowProperty(xfi, event->xproperty.window, xfi->_NET_WM_STATE, 12, &nitems, &bytes, &prop); if (!status) { DEBUG_X11_LMS("No return _NET_WM_STATE, window is not maximized"); } for (i = 0; i < nitems; i++) { if ((Atom) ((UINT16**) prop)[i] == XInternAtom(xfi->display, "_NET_WM_STATE_MAXIMIZED_VERT", False)) { maxVert = TRUE; } if ((Atom) ((UINT16**) prop)[i] == XInternAtom(xfi->display, "_NET_WM_STATE_MAXIMIZED_HORZ", False)) { maxHorz = TRUE; } } XFree(prop); } if ((Atom) event->xproperty.atom == xfi->WM_STATE) { status = xf_GetWindowProperty(xfi, event->xproperty.window, xfi->WM_STATE, 1, &nitems, &bytes, &prop); if (!status) { DEBUG_X11_LMS("No return WM_STATE, window is not minimized"); } else { /* If the window is in the iconic state */ if (((UINT32) *prop == 3)) minimized = TRUE; else minimized = FALSE; XFree(prop); } } if (maxVert && maxHorz && !minimized && (xfi->window->rail_state != WINDOW_SHOW_MAXIMIZED)) { DEBUG_X11_LMS("Send SC_MAXIMIZE command to rail server."); xfi->window->rail_state = WINDOW_SHOW_MAXIMIZED; xf_rail_send_client_system_command(xfi, window->windowId, SC_MAXIMIZE); } else if (minimized && (xfi->window->rail_state != WINDOW_SHOW_MINIMIZED)) { DEBUG_X11_LMS("Send SC_MINIMIZE command to rail server."); xfi->window->rail_state = WINDOW_SHOW_MINIMIZED; xf_rail_send_client_system_command(xfi, window->windowId, SC_MINIMIZE); } else if (!minimized && !maxVert && !maxHorz && (xfi->window->rail_state != WINDOW_SHOW)) { DEBUG_X11_LMS("Send SC_RESTORE command to rail server"); xfi->window->rail_state = WINDOW_SHOW; xf_rail_send_client_system_command(xfi, window->windowId, SC_RESTORE); } } } else { if (xf_cliprdr_process_property_notify(xfi, event)) return TRUE; } return TRUE; }
static BOOL xf_event_ButtonRelease(xfInfo* xfi, XEvent* event, BOOL app) { int x, y; int flags; BOOL extended; rdpInput* input; Window childWindow; input = xfi->instance->input; x = 0; y = 0; flags = 0; extended = FALSE; switch (event->xbutton.button) { case 1: x = event->xbutton.x; y = event->xbutton.y; flags = PTR_FLAGS_BUTTON1; break; case 2: x = event->xbutton.x; y = event->xbutton.y; flags = PTR_FLAGS_BUTTON3; break; case 3: x = event->xbutton.x; y = event->xbutton.y; flags = PTR_FLAGS_BUTTON2; break; case 6: case 8: case 97: extended = TRUE; x = event->xbutton.x; y = event->xbutton.y; flags = PTR_XFLAGS_BUTTON1; break; case 7: case 9: case 112: extended = TRUE; x = event->xbutton.x; y = event->xbutton.y; flags = PTR_XFLAGS_BUTTON2; break; default: flags = 0; break; } if (flags != 0) { if (app) { /* make sure window exists */ if (xf_rdpWindowFromWindow(xfi, event->xbutton.window) == NULL) { return TRUE; } /* Translate to desktop coordinates */ XTranslateCoordinates(xfi->display, event->xbutton.window, RootWindowOfScreen(xfi->screen), x, y, &x, &y, &childWindow); } if (xfi->scale != 1.0) { /* Take scaling in to consideration */ x = (int) (x * (1.0 / xfi->scale)); y = (int) (y * (1.0 / xfi->scale)); } if (extended) input->ExtendedMouseEvent(input, flags, x, y); else input->MouseEvent(input, flags, x, y); } return TRUE; }
static BOOL xf_event_ButtonPress(xfInfo* xfi, XEvent* event, BOOL app) { int x, y; int flags; BOOL wheel; BOOL extended; rdpInput* input; Window childWindow; input = xfi->instance->input; x = 0; y = 0; flags = 0; wheel = FALSE; extended = FALSE; switch (event->xbutton.button) { case 1: x = event->xbutton.x; y = event->xbutton.y; flags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1; break; case 2: x = event->xbutton.x; y = event->xbutton.y; flags = PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON3; break; case 3: x = event->xbutton.x; y = event->xbutton.y; 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; x = event->xbutton.x; y = event->xbutton.y; flags = PTR_XFLAGS_DOWN | PTR_XFLAGS_BUTTON1; break; case 7: /* wheel right or forward */ case 9: /* forward */ case 112: /* Xming */ extended = TRUE; x = event->xbutton.x; y = event->xbutton.y; 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(xfi, event->xbutton.window) == 0) { return TRUE; } /* Translate to desktop coordinates */ XTranslateCoordinates(xfi->display, event->xbutton.window, RootWindowOfScreen(xfi->screen), x, y, &x, &y, &childWindow); } if (xfi->scale != 1.0) { /* Take scaling in to consideration */ x = (int) (x * (1.0 / xfi->scale)); y = (int) (y * (1.0 / xfi->scale)); } if (extended) input->ExtendedMouseEvent(input, flags, x, y); else input->MouseEvent(input, flags, x, y); } } 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)); } 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)); } if (extended) input->ExtendedMouseEvent(input, flags, x, y); else input->MouseEvent(input, flags, x, y); } } return TRUE; }